|
Search this group's discussions
|
"Filesize was zero" problem
|
Hi all!
I have a small Emacs hack that lets me upload images to Flickr. It creates the HTTP POST on its own and does not rely on any libraries outside Emacs. When I was testing it today it did not work anymore. Last time it worked was probably sometime last year. Looking at the response I get I see the error "Filesize was zero". I cannot understand it, my POST looks OK. Here it is, with some sensitive stuff stripped away. I replaced all CR chars with "" so that it can be read. The test below is a download of a very small JPEG file. I can add tags etc without problems, so my signature and auth and stuff works well.
OK, here goes:
POST /services/upload/ HTTP/1.1
User-Agent: Emacs
Host: api.flickr.com
Content-Length: 3810
Content-Type: multipart/form-data; boundary="MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY"
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY
Content-Disposition: form-data; name="auth_token"
MY TOKEN
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY
Content-Disposition: form-data; name="api_key"
MY API KEY
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY
Content-Disposition: form-data; name="title"
muugallery.jpg
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY
Content-Disposition: form-data; name="tags"
emacs
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY
Content-Disposition: form-data; name="api_sig"
MY SIG
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY
Content-Disposition: form-data; name="photo"; filename="filename.jpg"
FILE CONTENT GOES HERE
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY--
Any ideas?
/Mathias
Posted at 11:17AM, 10 November 2007 PDT
(permalink)
|
|
Seems like the CR-markers were stripped away. I have replaced them with [CR] here instead:
POST /services/upload/ HTTP/1.1[CR]
User-Agent: Emacs[CR]
Host: api.flickr.com[CR]
Content-Length: 3810[CR]
Content-Type: multipart/form-data; boundary="MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY"[CR]
[CR]
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY[CR]
Content-Disposition: form-data; name="auth_token"[CR]
[CR]
MY TOKEN[CR]
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY[CR]
Content-Disposition: form-data; name="api_key"[CR]
[CR]
MY API KEY[CR]
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY[CR]
Content-Disposition: form-data; name="title"[CR]
[CR]
muugallery.jpg[CR]
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY[CR]
Content-Disposition: form-data; name="tags"[CR]
[CR]
emacs[CR]
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY[CR]
Content-Disposition: form-data; name="api_sig"[CR]
[CR]
MY SIG[CR]
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY[CR]
Content-Disposition: form-data; name="photo"; filename="filename.jpg"[CR]
[CR]
FILE CONTENT GOES HERE[CR]
--MMMYYYYYBBBBOOOOUUUNNNNDDDDAAAARRRRYYYY--[CR]
Posted 55 months ago.
(permalink)
|
|
When I did my python uploader, I noticed that flickr's mime parser was a lot pickier than the rfcs might lead you to expect. In particular, I needed to explicitly give a content-type in each section (and it needed to be correct for photo, ie. image/jpeg, though text/plain was fine for the others.) (A bigger problem was that it *had* to have a filename= entry, but you've *got* that...) Of course, this doesn't explain it having worked before and not now.
Also, I POST to www.flickr.com, not api.flickr.com, don't know if that matters...
www.flickr.com/services/api/upload.example.html
has some raw output of an example that I found useful at the time.
(Also: would love to get ahold of your elisp code; my python code is at www.thok.org/intranet/python/exif/index.html and the flickr_post.py there in particular.)
Posted 55 months ago.
(permalink)
|
|
strfilename1="c:\a.jpg"
i give values instead of my api , my api sig, my auth token
oHttp.open "POST", "http://api.flickr.com/services/upload/", False
oHttp.setRequestHeader "Content-Type", "multipart/form-data, boundary=AaB03x"
'assemble the body. send one field and two files
strBody = _
"--AaB03x" & vbCrLf & _
"Content-Disposition: form-data; name=""api_key""" & vbCrLf & vbCrLf & _
"my api" & vbCrLf & _
"--AaB03x" & vbCrLf & _
"Content-Disposition: form-data; name=""api_sig""" & vbCrLf & vbCrLf & _
"my api sig" & vbCrLf & _
"--AaB03x" & vbCrLf & _
"Content-Disposition: form-data; name=""auth_token""" & vbCrLf & vbCrLf & _
"my auth token" & vbCrLf & _
"--AaB03x" & vbCrLf & _
"Content-Disposition: attachment; name=""photo""; filename=""" & strFileName1 & """" & vbCrLf & _
"Content-Transfer-Encoding: binary" & vbCrLf & _
"Content-Type: image/JPG" & vbCrLf & vbCrLf & _
strImage & vbCrLf & _
"--AaB03x--"
'must convert to byte array because of binary zeros
aPostData = StrConv(strBody, vbFromUnicode)
'send it
oHttp.send aPostData
'check the feedback
Debug.Print oHttp.responseText
Text1.Text = oHttp.responseText
Posted 31 months ago.
(permalink)
|
|
i am getting error
file size was zero
plz help me
Posted 31 months ago.
(permalink)
|
|
Hi,
Did you find the cause of this error? I am also getting 'filesize was zero' error and I cannot figure out why.
Thanks.
Posted 22 months ago.
(permalink)
|
|
Problem solved.
Posted 22 months ago.
(permalink)
|
|
brakjoller wrote: I have a small Emacs hack that lets me upload images to Flickr.
Man, some people live in a different world.
Posted 22 months ago.
(permalink)
|
Would you like to comment?
Sign up for a free account, or sign in (if you're already a member).
|
|