<br><br><div class="gmail_quote">On Thu, Sep 10, 2009 at 12:31 PM, deepak gupta <span dir="ltr">&lt;<a href="mailto:dg288_mits@yahoo.co.in">dg288_mits@yahoo.co.in</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
<div>Hi All,</div>
<div> </div>
<div>How to send 1 GB Zip file to some remote machine using HTTP/HTTPS?</div>
<div> </div>
<div>As of now :</div>
<div>I am running a http listner in to remote machine.</div>
<div>I want to copy a file from local system to the remote machine where my HTTP/HTTPS Listner is running.</div>
<div>Currently i am comressing the file, then reading the file and sending the contents to the remote agent as a string.</div>
<div>At Remote agent , i am reading the string content and writing the same in to the file.</div>
<div> </div>
<div>this methord is OK when the file size is small ,like 100 MB or 200 MB.</div>
<div> </div>
<div>But it will give problem when i will transfer the large file say 1GB or 2 GB.</div>
<div>because till the file writing contents will be in the memory, so possible errors can come as out of memory or it may not be able to send the large file so socket error can also come.</div>
<div> </div></td></tr></tbody></table></blockquote><div><br>I just wrote some code to do something very similar: <br><br><a href="http://github.com/CarlFK/veyepar/blob/master/dj/scripts/blip_uploader.py">http://github.com/CarlFK/veyepar/blob/master/dj/scripts/blip_uploader.py</a><br>
<br>It is a bit messy, mainly because it has to send the size of the whole post including the metadata.   but it does not do <br>x+=file(&#39;foo.ogg&#39;,&#39;rb&#39;).read()<br><pre>h = httplib.HTTPConnection(host)<br>h.putheader(&quot;content-length&quot;,len(x) )<br>
h.send(x)</pre>which was crashing when foo.avi 600meg<br><br>The part that actually transferes the file:<br><br><pre><div class="line" id="LC127">        f = open(filename,&#39;rb&#39;)</div><div class="line" id="LC128">        block=f.read(10000)</div>
<div class="line" id="LC129">        while block:</div><div class="line" id="LC130">            h.send(block)</div><div class="line" id="LC131">            bytes_sent += len(block)</div><div class="line" id="LC132">            if progress: progress(bytes_sent,datalen)</div>
<div class="line" id="LC133">            block=f.read(10000)</div></pre><br>If someone can figure out how to refacter PostMultipart so it isn&#39;t so messy...  <br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">

<div>So is there any other way to transfer the large file, size i have mention above using HTTP/HTTPS.</div>
<div> </div>
<div>Please mention if i can do it by using some other protocol.</div>
<div> </div>
<div>Thanks and Regards,</div>
<div>Deepak</div><font color="#888888">
</font><div> </div><div class="hm">
<div> </div></div></td></tr></tbody></table><div class="hm"><br>
      <hr size="1"> See the Web&#39;s breaking stories, chosen by people like you. Check out <a href="http://in.rd.yahoo.com/tagline_buzz_1/*http://in.buzz.yahoo.com/" target="_blank"> Yahoo! Buzz</a>.</div><br>_______________________________________________<br>

BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Carl K<br>