<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Заливка файлов на filemail.com]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=13727&amp;type=atom" />
	<updated>2019-08-14T20:23:47Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=13727</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135616#p135616" />
			<content type="html"><![CDATA[<p>Я просто роутер выключаю и включаю.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T20:23:47Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135616#p135616</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135615#p135615" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Только поздно слишком. У меня при превышении лимита ответ 500, следовательно бесконечный цикл с ноликом.</p></blockquote></div><p>Точно. Исправил.<br />Кстати, я обхожу лимит айпи через телефон в режиме модема.<br />При переключении на c 4g на 2g и обратно - айпи меняется.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-14T20:21:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135615#p135615</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135614#p135614" />
			<content type="html"><![CDATA[<p>Можно, конечно еще размер проверять и добавить загрузку нескольких файлов, но у меня пока такой надобности не было.<br />При нескольких файлов, цикл загрузки повторяется для каждого файла отдельно.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-14T20:15:19Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135614#p135614</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135613#p135613" />
			<content type="html"><![CDATA[<p>Только поздно слишком. У меня при превышении лимита ответ 500, следовательно бесконечный цикл с ноликом.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T20:14:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135613#p135613</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135612#p135612" />
			<content type="html"><![CDATA[<p>Лимит загрузок у меня проверяется.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-14T20:06:43Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135612#p135612</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135611#p135611" />
			<content type="html"><![CDATA[<p>В данном случае браузер сразу сообщение выводит и просит оставаться на сайте, так как при появлении интернета загрузка продолжится.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-14T20:06:12Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135611#p135611</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135609#p135609" />
			<content type="html"><![CDATA[<p>Кроме того, может быть просто превышен лимит загрузок за сессию.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T19:56:23Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135609#p135609</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135608#p135608" />
			<content type="html"><![CDATA[<p>Зачем такие радикальные меры? Да и причина не только в отсутствии интернета может быть, может на сайте что-то не так. Браузер обычно через какое-то время ожидания сообщение об отсутствии соединения выводит.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T19:45:14Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135608#p135608</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135607#p135607" />
			<content type="html"><![CDATA[<p>Через браузер вроде так и сделано.<br />Надо будет на ночь без инета поставить, а утром включить инет и проверить будет загружаться или нет.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-14T19:39:32Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135607#p135607</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135606#p135606" />
			<content type="html"><![CDATA[<p>Ну, будет без конца крутиться.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T19:31:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135606#p135606</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135605#p135605" />
			<content type="html"><![CDATA[<p>А зачем нужно ограничение?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-14T19:14:30Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135605#p135605</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135604#p135604" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><div class="codebox"><pre><code>      if (HTTP.Status = 200)
         break</code></pre></div></blockquote></div><p>А если всё время по какой-то причине не равно? Должно быть, наверно, ограничение количества итераций.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T19:02:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135604#p135604</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135603#p135603" />
			<content type="html"><![CDATA[<p>Вставил свой вариант с проверкой статуса в первое сообщение темы.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-14T18:57:20Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135603#p135603</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135599#p135599" />
			<content type="html"><![CDATA[<p>Пробовал ещё только один раз WinHttpRequest и SafeArray создавать, ощутимой разницы не заметил.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T16:22:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135599#p135599</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Заливка файлов на filemail.com]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=135598#p135598" />
			<content type="html"><![CDATA[<p>В один поток:<br /></p><div class="codebox"><pre><code>#MaxThreads 255
SetBatchLines, -1
start := A_TickCount
Clipboard := UploadFileToFilemail(&quot;from@gmail.com&quot;, &quot;to@gmail.com&quot;, &quot;file&quot;, &quot;hello!&quot;)
MsgBox, % (A_TickCount - start)//1000

UploadFileToFilemail(from, to, subject, message) {
   FileSelectFile, filePath,,, Choose file to upload, All Files (*.*)
   if !filePath
      ExitApp
   
   json := Init(from, to, subject, message)
   if error := JsonRead(json, transferID, transferKEY, transferURL)
      Return error
      
   SplitPath, filePath, fileName
   fileName := URIEncode(fileName)
   oFile := FileOpen(filePath, &quot;r&quot;)
   fileSize := oFile.length
   chunkSize := 5242880
   chunksNumber := Ceil(fileSize/chunkSize)
   lastChunkSize := mod(fileSize, chunkSize)
   info := {parts: chunksNumber}
   CoordMode, ToolTip
   ToolTip, % &quot;parts: &quot; chunksNumber, 3, 3, 1
   Loop % chunksNumber {
      currentChunkSize := A_Index = chunksNumber ? lastChunkSize : chunkSize
      link := transferURL . &quot;?transferid=&quot; . transferID . &quot;&amp;transferkey=&quot; . transferKEY
           . &quot;&amp;chunksize=&quot; . chunkSize . &quot;&amp;thefilename=&quot; . fileName . &quot;&amp;totalsize=&quot; . fileSize
           . &quot;&amp;chunks=&quot; . chunksNumber  . &quot;&amp;chunk=&quot; . A_Index - 1 . &quot;&amp;runtime=html5&amp;retry=0&quot;
      SendChunk(oFile, currentChunkSize, link, info)
   }
   oFile.Close()
   ToolTip,,,, 1
   Return GetUrl(transferID, transferKEY)
}

Init(from, to, subject, message) {
   from := URIEncode(from), to := URIEncode(to), subject := URIEncode(subject), message := URIEncode(message)
   body := &quot;sourcedetails=plupload(html5)+`%40+https`%3A`%2F`%2Fwww.filemail.com`%2F&amp;to`%5B`%5D=&quot;
          . to &quot;&amp;from=&quot; from &quot;&amp;subject=&quot; subject &quot;&amp;message=&quot; message &quot;&amp;days=7&amp;confirmation=true&quot;
   Return SetRequest(body, &quot;initialize&quot;)
}

JsonRead(json, ByRef transferID, ByRef transferKEY, ByRef transferURL) {
   RegexMatch(json, &quot;s)&quot;&quot;transferid&quot;&quot;: &quot;&quot;(.+?)&quot;&quot;.+?&quot;&quot;transferkey&quot;&quot;: &quot;&quot;(.+?)&quot;&quot;.+?&quot;&quot;transferurl&quot;&quot;: &quot;&quot;(.+?)&quot;&quot;&quot;, match)
   transferID := match1, transferKEY := match2, transferURL := match3
   if !(transferID &amp;&amp; transferKEY &amp;&amp; transferURL)
      Return json
}

GetUrl(transferID, transferKEY) {
   body := &quot;transferid=&quot; . transferid . &quot;&amp;transferkey=&quot; . transferkey . &quot;&amp;failed=false&quot;
   responseText := SetRequest(body, &quot;complete&quot;)
   RegexMatch(responseText, &quot;&quot;&quot;downloadurl&quot;&quot;: &quot;&quot;\K[^&quot;&quot;]+&quot;, url)
   Return url ? url : responseText
}

SetRequest(body, mode) {
   HTTP := ComObjCreate(&quot;Msxml2.XMLHTTP.6.0&quot;)
   HTTP.Open(&quot;POST&quot;, &quot;https://www.filemail.com/api/transfer/&quot; . mode, false)
   HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;)
   HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
   HTTP.SetRequestHeader(&quot;Source&quot;, &quot;Web&quot;)
   HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
   HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
   HTTP.Send(body)
   Return HTTP.responseText
}

SendChunk(ByRef oFile, size, link, info) {
   safeArr := ComObjArray(0x11, size) ; Create SAFEARRAY = VT_ARRAY|VT_UI1
   pData := NumGet( ComObjValue(safeArr) + 8 + A_PtrSize )
   oFile.RawRead(pData + 0, size)
   HTTP := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
   HTTP.Open(&quot;POST&quot;, link, true)
   HTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/octet-stream&quot;)
   HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko&quot;)
   HTTP.Send(safeArr)
   HTTP.WaitForResponse()
   if ( (s := HTTP.Status) != 200)
      throw Exception(&quot;Upload Error. Status: &quot; . s)
   ToolTip, % &quot;rest: &quot; . (--info.parts), 3, 3, 1
}

URIEncode(str, encoding := &quot;UTF-8&quot;)  {
   VarSetCapacity(var, StrPut(str, encoding))
   StrPut(str, &amp;var, encoding)

   While code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)  {
      bool := (code &gt; 0x7F || code &lt; 0x30 || code = 0x3D)
      UrlStr .= bool ? &quot;%&quot; . Format(&quot;{:02X}&quot;, code) : Chr(code)
   }
   Return UrlStr
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-08-14T15:40:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=135598#p135598</id>
		</entry>
</feed>
