photo / frontend

The official @github repository of the Trovebox frontend software. A photo sharing and photo management web interface for data stored "in the cloud" (i.e. Amazon S3, Rackspace CloudFiles, Google Storage).
https://trovebox.com
Apache License 2.0
1.38k stars 244 forks source link

Download original comes with wrong extension #958

Closed patricksan closed 11 years ago

patricksan commented 12 years ago

When clicked on download original I get the filename.jpg.html

Eg: http://ps.openphoto.me/photo/ceq/download returns _IMG2722.jpg.html

I just rename the file and the photo is okay.

I'm using Safari.

hfiguiere commented 12 years ago

The question is what mime type does the HTTP server return? I think that Safari might be adding the extension.

jmathai commented 12 years ago

To check the headers you'd need something like http live headers or a similar addon. The download link does a http redirect to the file at the underlying storage system.

patricksan commented 12 years ago

There is something really strange with this file. If you open the .html it has some html information:

in the bottom:

Of course, if I rename the file to .jpg the photo is there: photo

sneakypete81 commented 12 years ago

For reference, these are the headers returned by openphoto.me when downloading a photo.

Unsurprisingly, Firefox identifies this as an HTML document and offers to open it in Firefox. It sounds like Safari is taking the HTML content-type even more seriously.

http://account.openphoto.me/photo/296/download

GET /photo/296/download HTTP/1.1
Host: account.openphoto.me
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Referer: http://account.openphoto.me/p/296
Cookie: ............

HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Description: File Transfer
Content-Disposition: attachment; filename=opmelfE27R.jpg
Content-Encoding: gzip
Content-Type: text/html
Date: Thu, 13 Sep 2012 07:48:49 GMT
Server: Apache/2.2.20 (Ubuntu)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Connection: keep-alive
hfiguiere commented 12 years ago

There is definitely something wrong.

jmathai commented 11 years ago

Is the problem the content type? We don't set that explicitly but could.

Content-Type: text/html
patricksan commented 11 years ago

We could give a try.

hfiguiere commented 11 years ago

If we can, we should.

jmathai commented 11 years ago

Can someone make a photo with this problem either public or share it with jaisen@jmathai.com so I can reproduce?

patricksan commented 11 years ago

So I enabled download original in my account: http://ps.openphoto.me.

Steps to reproduce:

  1. Open on image, eg: http://ps.openphoto.me/p/cu2
  2. Click in Download original
  3. Voilá!!

I tested on Safari.

jmathai commented 11 years ago

Fixed. I was only able to reproduce it with Safari. Firefox and Chrome both assumed the proper mime type.

jmathai commented 11 years ago

The issue where html was included in the file was fixed by this

patricksan commented 11 years ago

Great! Safari is a special browser, needs special treatment. :-)

alanz commented 11 years ago

I am still seeing this issue on the my.openphoto.me site

$ curl -D /tmp/headers 'http://alanz.openphoto.me/photo/m/download' -O /dev/nul

cat /tmp/headers
HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Description: File Transfer
Content-Disposition: attachment; filename="IMG_5874.JPG"
Content-Type: text/html
Date: Wed, 17 Oct 2012 12:17:24 GMT
Server: Apache/2.2.20 (Ubuntu)
Set-Cookie: EpiSession=7fb159662481322d075239bd00f5fa6f; expires=Thu, 18-Apr-2013 03:11:47 GMT; path=/; domain=.openphoto.me
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.6-13ubuntu3.2
transfer-encoding: chunked
Connection: keep-alive
jmathai commented 11 years ago

@alanz What are you using as your storage service? If the file was somehow deleted from the "source" then the download page will render a 404 in HTML. But if that happend the Content-D* headers should not be present so I think there's still an issue in here somewhere.

Will reopen with more info...

alanz commented 11 years ago

It is running on the official openphoto hosted service.

The download takes place fine, it is just that the mime type is set to text/html, so safari saves it with a html extension. If I rename the file I can see it is the image in question.

Alan

On Wed, Oct 17, 2012 at 6:55 PM, Jaisen Mathai notifications@github.comwrote:

@alanz https://github.com/alanz What are you using as your storage service? If the file was somehow deleted from the "source" then the download page will render a 404 in HTML. But if that happend the Content-D* headers should not be present so I think there's still an issue in here somewhere.

Will reopen with more info...

— Reply to this email directly or view it on GitHubhttps://github.com/photo/frontend/issues/958#issuecomment-9534860.

jmathai commented 11 years ago

Reopening to investigate.