Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File upload fails for images #5

Open
jsiegle opened this issue Apr 9, 2012 · 8 comments
Open

File upload fails for images #5

jsiegle opened this issue Apr 9, 2012 · 8 comments

Comments

@jsiegle
Copy link

jsiegle commented Apr 9, 2012

In the latest version of Fish, I can use the -f flag to upload text files as the content of tags, but I can't get it to work with images. I tried to follow the example code as closely as possible.

The following command works:

fish tag -f 'r&s records' comment=randscomment.txt

But these all fail:

fish tag -f -M image/gif 'r&s records' image=randslogo.gif
fish tag -f -M image/jpg 'r&s records' image=randslogo.jpg
fish tag -f -M image/png 'r&s records' image=randslogo.png

The output is:

'Fish failure:'
'ascii' codec can't decode byte 0x89 in position 0: ordinal not in range(128)

It doesn't matter whether I specify the MIME type or not.

I'm using bash and Python 2.7.2 in OS X 10.7, if that matters.

Thanks in advance for looking into this.

@njr0
Copy link
Owner

njr0 commented Apr 9, 2012

Hi jsiegle

Sorry you're having trouble. I can't really look at this properly today, but I just did this and it worked:

fish tag -f 'r&s records' image.png=FishIcon512x512.png

on OS X 10.6.8 (Snow Leopard). You can see it at:

http://fluiddb.fluidinfo.com/about/r%26s%20records/njr/image.png

Compared with yours there are two obvious differences:

  1. I didn't specify the MIME type (fish knows about common image types etc.)
  2. I added an extension to the tag, which is probably a good idea anyway.

But I would expect yours to work. If I miss off the .png on the tag, it still works.

fish tag -f 'r&s records' image=FishIcon512x512.png

with the result at

http://fluiddb.fluidinfo.com/about/r%26s%20records/njr/image

and if I put in the MIME specification it continues to work.

fish tag -M image/png -f 'r&s records' image2=FishIcon512x512.png

with the result at

http://fluiddb.fluidinfo.com/about/r%26s%20records/njr/image2

So I'm not sure what's up.

It looks as if Fish is trying to read your images as text files (with open(filename) rather than open(filename, 'b')), but it shouldn't be doing that. So I guess the obvious possibilities are:

Lion vs. Snow Leopard
Python version (my default it 2.6.5, though I often use 2.7)
The particular image.
Some detail of your library/path setup vs. mine.

Could you put the image you're trying somewhere I can grab it and try it?
Also, you might want to try using the png that worked for me (which, obviously, you can get from any of the URLs above).

I'll try to look at this tomorrow, but don't think I'll be able to today.

Regards

Nick

Otherwise, I'll try Lion and 2.7 and stuff

@jsiegle
Copy link
Author

jsiegle commented Apr 9, 2012

Thanks for the quick response!

I tried the same commands with your image, but it didn't help. I also tried to replicate everything on Xubuntu, and I get the same problem.

Let me know if you get a chance to look into this further, or if you can think of anything else that might be different about my configuration.

Best,
Josh

@njr0
Copy link
Owner

njr0 commented Apr 10, 2012

Hi Josh

If you get the same behaviour on two different systems that starts to sound as if maybe there's something special about my setup that I'm unaware of, but I have several systems I can try things on, so I will try to get further.

I assume you're running version 4.34? (You can use fish -V to check.)

Assuming you are running that version, could you try running with -D (debug) and see where it fails? From the error message, I'd guess it must be line 1309 or 1312 in fishlib.py, but it shouldn't be there, it should be at line 1318 (reading it in binary mode).

Nick

@jsiegle
Copy link
Author

jsiegle commented Apr 10, 2012

Yes, the version is 4.34. I cloned it last week.

Looks like it's actually line 554 of fishlib.py (the http request), which calls httplib2, then httplib, and finally fails at line 809 of httplib.py with a UnicodeDecodeError.

Not sure if this is an anticipated use of Fluidinfo, but here's the error message: http://fluidinfo.com/about/#!/errormsg

Does that make any sense?

@njr0
Copy link
Owner

njr0 commented Apr 10, 2012

Ah, that probably does explain it. I switched to use requests 0.9.1 rather than httplib2 by default because (in my experience) httplib2 is really unreliable. I guess it probably means you don't have requests installed.

If you do

pip install requests==0.9.1

I suspect everything will work (assuming you have pip).

I'd like to remove the httplib2 stuff completely, but there was a problem with requests 1.0.something that made me a bit nervous. I'll try it with the latest version and if that's OK perhaps just delete the httplib2 stuff and make it a dependency.

Sorry again for the pain. Let me know if this doesn't work for you.

Nick

@jsiegle
Copy link
Author

jsiegle commented Apr 10, 2012

Looks like the requests library ends up calling the same function in httplib, with the same ultimate result:

http://fluidinfo.com/about/#!/errormsg

@njr0
Copy link
Owner

njr0 commented Apr 10, 2012

Josh

That;'s disappointing, though you will have fewer problems with requests.

The good news is I can now reproduce it on Lion with python2.7, so I should be able to chase it down.

Nick

@njr0
Copy link
Owner

njr0 commented Apr 10, 2012

OK, it looks like it's a problem in python 2.7, but not python 2.6, which is slightly strange, but I think I have seen something like it before. I'll try to figure out what it is. (It works fine for me in python 2.6 under Lion.)

Nick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants