Flickr API / Discuss

Current Discussion

Searching users on the API
Latest: 12 hours ago
2048 and 1600 size
Latest: 3 days ago
New Group APIs
Latest: 3 days ago
Null url field in oembed response
Latest: 4 days ago
flexplore
Latest: 4 days ago
Display a specific album in WebSite
Latest: 4 days ago
oEmbed doesn't provide large size URL?
Latest: 5 days ago
ObjectiveFlickr Framework 2.0 for Mac and iPhone Released
Latest: 6 days ago
Survey on Web APIs Popularity and Support Forums
Latest: 6 days ago
Flickr API changed within the last 24 hours? its broken suddenly
Latest: 6 days ago
New API to modify camera information of the photo?
Latest: 8 days ago
Who is admin and where is my item in the pool
Latest: 8 days ago
More...

Search this group's discussions

"Filesize was zero" problem

view profile

brakjoller  Pro User  says:

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)

view photostream

brakjoller  Pro User  says:

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)

view photostream

Mark Eichin  Pro User  says:

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)

view photostream

kawal0000 says:

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)

view photostream

kawal0000 says:

i am getting error
file size was zero
plz help me
Posted 31 months ago. (permalink)

view photostream

gmariaandrea2003 says:

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)

view photostream

gmariaandrea2003 says:

Problem solved.
Posted 22 months ago. (permalink)

view photostream

Eli the Bearded  Pro User  says:

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).

RSS 2.0 feedSubscribe to a feed of stuff on this page...</!!> Feed – Subscribe to Flickr API discussion threads