cffile upload to s3 content type issue

374 views
Skip to first unread message

Bien

unread,
Jul 13, 2010, 10:50:23 AM7/13/10
to Railo
Hi all,

I'm using CFFILE to upload files to Amazon S3, but all uploaded files
are assigned with a content type of "application." Is there any way
to change this? For the most part it's not actually a problem but
it's forcing files to download in Safari. For HTML files I'd like to
assign "text/html" as the content-type, but instead it's forcing a
download.

Here's an example:
http://cdesign.s3.amazonaws.com/index.html
-- I uploaded this file manually using S3Fox:
-- it works fine in all browsers.

http://m.theclientspace.com.s3.amazonaws.com/rlrlrxzxfloueiulul/client_area/crgstaff/index.html
-- I uploaded this using CFFILE to my S3 folder.
-- It works well in all browsers except Safari - Safari forces the
file to download...

For the moment, I've created a workaround that looks for Safari and
does a CFHTTP/CFOUTPUT of the html contents, but it's far from ideal.
Here's that link:
http://meetcrg.theclientspace.com/htmlview/arrlclaxuutidivucuclbltuvuvlxubiuucilldlrifivxaijltujioiaielturuiucxzlaxfiuuduaxcucioljxtuclzidujuiuarilautlaxdlaurueuiuzialxxllxucxiuuulltufuluzurlrlaiaiaueuoublrluulixutifurlxiburuiiexoueilieubuaujxjllljxtiuucizuelcualxidu

Any help you could provide would be great! Thanks!
Bien




Todd Rafferty

unread,
Jul 13, 2010, 11:15:28 AM7/13/10
to ra...@googlegroups.com
This is a mime-type issue and cffile isn't responsible for setting the mime-type of the file as far as I can tell. I'm downloading Safari atm to do some testing.
--
~Todd Rafferty ** Volunteer Railo Open Source Community Manager ** http://getrailo.org/

Todd Rafferty

unread,
Jul 13, 2010, 11:21:37 AM7/13/10
to ra...@googlegroups.com
I'm using Safari 5.0 (7533.16) on windows and I can browse to http://m.theclientspace.com.s3.amazonaws.com/rlrlrxzxfloueiulul/client_area/crgstaff/index.html successfully. It does not prompt me to download. The full page renders.

Bien

unread,
Jul 13, 2010, 6:36:36 PM7/13/10
to Railo
Hi Todd,

That's interesting, it's forcing me to download the page. I'm using
Safari on PC but I'll check on a Mac too - are you using a Mac?

Bien


On Jul 13, 11:21 am, Todd Rafferty <t...@getrailo.org> wrote:
> I'm using Safari 5.0 (7533.16) on windows and I can browse tohttp://m.theclientspace.com.s3.amazonaws.com/rlrlrxzxfloueiulul/clien....

Bien

unread,
Jul 13, 2010, 6:39:23 PM7/13/10
to Railo
Todd,

Weird - I tried it on Safari on the Mac just now and it forced a
download as well. I can see, when looking at the HTTP headers on S3
that the file is marked with a content type=application when it should
be content type=text/html -

Do you know if I can use railo's built-in S3 tools to modify that
content-type?

Bien

Todd Rafferty

unread,
Jul 13, 2010, 6:45:29 PM7/13/10
to ra...@googlegroups.com
I'm on Windows XP and it downloaded it as is in Safari. No forced download option.

If this is via cffile/S3, then you need to open a (bug? enhancement?) ticket in JIRA and ask to give us options to override that ( http://jira.jboss.org/browse/RAILO ).

Please include the HTTP headers with the ticket and any sample code that you're using. Please scrub your key / secret token, don't make that public.

On Tue, Jul 13, 2010 at 6:39 PM, Bien <bien.co...@gmail.com> wrote:
Todd,

Weird - I tried it on Safari on the Mac just now and it forced a
download as well.  I can see, when looking at the HTTP headers on S3
that the file is marked with a content type=application when it should
be content type=text/html -

Do you know if I can use railo's built-in S3 tools to modify that
content-type?

Bien

Peter Boughton

unread,
Jul 13, 2010, 6:48:01 PM7/13/10
to ra...@googlegroups.com
Not certain if this is the same issue, but:

> When you upload a file to S3 you have to set the Content-Type header.

From http://stackoverflow.com/questions/579644

My guess is that cffile with the S3 resource it isn't setting the
Content-Type header?

If you can do a quick bit of HTTP sniffing to determine what headers
are sent and confirm if that one's missing - if it is then it's a bug
in the S3 resource I guess, so needs a Jira.

Todd Rafferty

unread,
Jul 13, 2010, 6:55:12 PM7/13/10
to ra...@googlegroups.com
btw, here's proof...? 
screenshot.png

idtDev01

unread,
Mar 7, 2014, 4:54:21 PM3/7/14
to ra...@googlegroups.com
I'm wondering if this problem was ever resolved.  I'm having the same issue where uploading a pdf file to S3 via cffile does not properly set the Content-Type header and causes the pdf to hang in Chrome and Safari.  Basically the pdf says that it's loading in the browser, but never displays.  Some HTTP sniffing reveals that the Content-Type is sent, but it's set to "application" instead of "application/pdf".

The Request for a pdf
PUT /portals%2F1000%2Fimages%2Ftest.pdf HTTP/1.1
Content-Type: application
Content-Length: 104247
Date: Fri, 07 Mar 2014 21:20:08 GMT
x-amz-acl: public-read
Authorization: AWS redacted
User-Agent: Railo
Host: redacted

I've verified that the mime types in both IIS and Apache Tomcat are set to "application/pdf".  I also tried uploading a jpg to see if there was any difference, and it appears as if the Content-Type is always set to "application" no matter what the file extension is.

The Request for a jpg
PUT /portals%2F1000%2Fimages%2Ftest.jpg HTTP/1.1
Content-Type: application
Content-Length: 100481
Date: Fri, 07 Mar 2014 21:51:00 GMT
x-amz-acl: public-read
Authorization: AWS redacted
User-Agent: Railo
Host: redacted

I could work around this issue if there was a way to set the Content-Type header manually.

Todd

unread,
Mar 8, 2014, 1:28:08 PM3/8/14
to ra...@googlegroups.com
Maybe something has changed, but I was under the impression you had to set the ACL information yourself when working with S3. Which should also include the content type?




--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
---
You received this message because you are subscribed to the Google Groups "Railo" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/railo/281da8a2-5e16-49ed-ad35-247fb51b4b41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rushglen

unread,
Mar 9, 2014, 12:50:57 AM3/9/14
to ra...@googlegroups.com
try using "mimeType" instead of "contentType" (or try both)

Andrew

idtDev01

unread,
Mar 11, 2014, 2:31:32 PM3/11/14
to ra...@googlegroups.com
We set the file permissions with a bucket policy, so there is no need for us to set the ACL information via StoreSetACL().  The HTTP header information doesn't fall into the ACL functionality anyway, it falls into the metadata that can be set with a call to the StoreSetMetadata() function after the upload.  It looks like this function is not currently supported by railo anyway (No matching function [STORESETMETADATA] found).
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSd160b5fdf5100e8f-4439fdac128193edfd6-7efc.html

It's my feeling that the content-type header should either be an attribute set within cffile OR automatically set the content-type by referencing the server's mime-types so that there isn't a need to call a second function to re-set the http header after it's already been set incorrectly by cffile.  I have a feeling that using StoreSetMetadata() to set the HTTP header after the fact would also cause duplicate content if version control is turned on as well, effectively doubling your storage requirements for no reason.

By not having the ability to specify a Content-Type header with cffile or to set it manually via StoreSetMetadata(), it really forces you to use a S3 cfc wrapper instead of the built in S3 functionality for cffile.  Here is a link to a blog that describes the same issue:
http://www.cfelements.com/2012/04/coldfusion-railo-to-aws-s3-using.html
Reply all
Reply to author
Forward
0 new messages