Problems uploading files

171 views
Skip to first unread message

Jean-Bernard van Zuylen

unread,
Jul 11, 2012, 9:15:42 AM7/11/12
to taffy...@googlegroups.com
Hi,

I'm trying use to upload file functionality from Taffy 1.1 but can't make it work.

I followed what is written on the Wiki about this topic but I'm always getting the following HTTP error:

400 You must specify a content-type. Aborting request.

I've been looking in the file api.cfc but couldn't find any code handling the content type multipart/form-data.

Jean-Bernard

Adam Tuttle

unread,
Jul 11, 2012, 3:56:58 PM7/11/12
to taffy...@googlegroups.com
Hi Jean-Bernard,

My first question is: How are your requests originating? Are they coming from a web-form? A native app on a mobile phone? CFHTTP? AJAX? Something else?

The error you're seeing indicates that Taffy can't tell how to decode the request. It's expecting one of the following in the Content-Type header:
  • application/x-www-form-urlencoded
  • multipart/form-data; boundary=[your boundary here]
  • application/json
  • text/json
Since none of those are set (possibly something else, possibly nothing set at all?) then Taffy doesn't know what to do.

You can use a proxy like Charles to see the raw contents of the HTTP request you're sending. That will be very helpful in debugging.

Adam
Jean-Bernard van Zuylen wrote:
You must specify a content-type

Jean-Bernard van Zuylen

unread,
Jul 12, 2012, 5:16:31 AM7/12/12
to taffy...@googlegroups.com
Hi Adam,

The requests are coming from CFHTTP on Railo:

<cfhttp url="http://api.local:7777/me/profile/picture"
        method="put"
        result="pictureResult">
  <cfhttpparam type="header" name="Authorization" value="Bearer 20F406E02B1261B7F0D7BDD8F5A1FF7A210C0EFF" />
  <cfhttpparam type="file" name="image" file="E:\Projects\logo.png" />
</cfhttp>

This is generating the following raw content:

PUT /me/profile/picture HTTP/1.1
Authorization: Bearer 20F406E02B1261B7F0D7BDD8F5A1FF7A210C0EFF
Accept-Encoding: gzip
User-Agent: Railo (CFML Engine)
Host: api.local:7777
Content-Length: 5015
Content-Type: multipart/form-data; boundary=H7bmC6a8bexOzEXmCMjNMEMba7DbaoajoSYk

--H7bmC6a8bexOzEXmCMjNMEMba7DbaoajoSYk
Content-Disposition: form-data; name="image"; filename="logo.png"
Content-Type: image/png
Content-Transfer-Encoding: binary

The Content-Type header seems to be set correctly.

When I check the code from the release 1.1, this error is returned on line 352 in api.cfc. If I look to the code around this line, I see code handling the content types application/x-www-form-urlencoded, application/json and text/json but nothing for multipart/form-data.

Jean-Bernard

Adam Tuttle

unread,
Jul 13, 2012, 7:23:39 PM7/13/12
to taffy...@googlegroups.com
Very odd indeed. I'll have to code up a test for this to verify that it's working. Been slammed at work this week. Might be able to get to it this weekend.

I wonder if this is a Railo-specific issue. It's possible that under the hood ACF sees "multipart/form-data" and converts it to application/x-www-form-urlencoded  (in memory, where we're looking)...

Anyway, I'll see about getting a test put together to (a) verify my install is still working, and (b) have you try it out on Railo. :)
      * application/x-www-form-urlencoded
      * multipart/form-data; boundary=[your boundary here]
      * application/json
      * text/json


    Since none of those are set (possibly something else, possibly
    nothing set at all?) then Taffy doesn't know what to do.

    You can use a proxy like Charles <http://www.charlesproxy.com/> to

Adam Tuttle

unread,
Jul 13, 2012, 8:04:56 PM7/13/12
to taffy...@googlegroups.com
Ok, I pushed the new test to the *develop* branch on github. It's at the bottom of TestCore.cfc.

To run the tests, first open /taffy/tests/ in your browser to initialize the api, then open /taffy/tests/tests/ to run the mxunit test suite. Of course, requires you have an /mxunit mapping or have it in your web root.

And if you're running Railo on Tomcat, you're going to want to add the additional servlet mapping for /taffy/tests/index.cfm/* to web.xml.

Let me know how you make out.

Adam

July 13, 2012 7:23 PM
Very odd indeed. I'll have to code up a test for this to verify that it's working. Been slammed at work this week. Might be able to get to it this weekend.

I wonder if this is a Railo-specific issue. It's possible that under the hood ACF sees "multipart/form-data" and converts it to application/x-www-form-urlencoded  (in memory, where we're looking)...

Anyway, I'll see about getting a test put together to (a) verify my install is still working, and (b) have you try it out on Railo. :)

Adam

Jean-Bernard van Zuylen wrote:
July 12, 2012 5:16 AM
Hi Adam,

The requests are coming from CFHTTP on Railo:

<cfhttp url="http://api.local:7777/me/profile/picture"
        method="put"
        result="pictureResult">
  <cfhttpparam type="header" name="Authorization" value="Bearer 20F406E02B1261B7F0D7BDD8F5A1FF7A210C0EFF" />
  <cfhttpparam type="file" name="image" file="E:\Projects\logo.png" />
</cfhttp>

This is generating the following raw content:

PUT /me/profile/picture HTTP/1.1
Authorization: Bearer 20F406E02B1261B7F0D7BDD8F5A1FF7A210C0EFF
Accept-Encoding: gzip
User-Agent: Railo (CFML Engine)
Host: api.local:7777
Content-Length: 5015
Content-Type: multipart/form-data; boundary=H7bmC6a8bexOzEXmCMjNMEMba7DbaoajoSYk

--H7bmC6a8bexOzEXmCMjNMEMba7DbaoajoSYk
Content-Disposition: form-data; name="image"; filename="logo.png"
Content-Type: image/png
Content-Transfer-Encoding: binary

The Content-Type header seems to be set correctly.

When I check the code from the release 1.1, this error is returned on line 352 in api.cfc. If I look to the code around this line, I see code handling the content types application/x-www-form-urlencoded, application/json and text/json but nothing for multipart/form-data.

Jean-Bernard

On Wednesday, July 11, 2012 9:56:58 PM UTC+2, Adam Tuttle wrote:
July 11, 2012 3:56 PM
Hi Jean-Bernard,

My first question is: How are your requests originating? Are they coming from a web-form? A native app on a mobile phone? CFHTTP? AJAX? Something else?

The error you're seeing indicates that Taffy can't tell how to decode the request. It's expecting one of the following in the Content-Type header:
  • application/x-www-form-urlencoded
  • multipart/form-data; boundary=[your boundary here]
  • application/json
  • text/json
Since none of those are set (possibly something else, possibly nothing set at all?) then Taffy doesn't know what to do.

You can use a proxy like Charles to see the raw contents of the HTTP request you're sending. That will be very helpful in debugging.


Adam

Jean-Bernard van Zuylen wrote:

Hi,

I'm trying use to upload file functionality from Taffy 1.1 but can't
make it work.

I followed what is written on the Wiki about this topic but I'm always
getting the following HTTP error:

400 You must specify a content-type. Aborting request.

I've been looking in the file api.cfc but couldn't find any code
handling the content type multipart/form-data.

Jean-Bernard


Jean-Bernard van Zuylen wrote:
You must specify a content-type
July 11, 2012 9:15 AM

Adam Tuttle

unread,
Jul 14, 2012, 10:03:01 AM7/14/12
to taffy...@googlegroups.com
One additional thing I'll point out is that, as long as your app server (whether it's ACF, Railo, OpenBD, Smith, or something else) puts the form fields from the multi-part form into the form scope, they should all be picked up. The one possibility I see is that on non-ACF app servers the content-type may trigger the error you're talking about. If that's the case we can probably add a branch to the IF-logic that does nothing except NOT throw the error.

Adam

Adam Tuttle wrote:

Ok, I pushed the new test to the *develop* branch on github. It's at
the bottom of TestCore.cfc.

To run the tests, first open /taffy/tests/ in your browser to
initialize the api, then open /taffy/tests/tests/ to run the mxunit
test suite. Of course, requires you have an /mxunit mapping or have it
in your web root.

And if you're running Railo on Tomcat, you're going to want to add the
additional servlet mapping for /taffy/tests/index.cfm/* to web.xml.

Let me know how you make out.

Adam


July 13, 2012 7:23 PM
Very odd indeed. I'll have to code up a test for this to verify that
it's working. Been slammed at work this week. Might be able to get to
it this weekend.

I wonder if this is a Railo-specific issue. It's possible that under
the hood ACF sees "multipart/form-data" and converts it to
application/x-www-form-urlencoded  (in memory, where we're looking)...

Anyway, I'll see about getting a test put together to (a) verify my
install is still working, and (b) have you try it out on Railo. :)

Adam

Jean-Bernard van Zuylen wrote:
Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>

July 11, 2012 3:56 PM
Hi Jean-Bernard,

My first question is: How are your requests originating? Are they
coming from a web-form? A native app on a mobile phone? CFHTTP? AJAX?
Something else?

The error you're seeing indicates that Taffy can't tell how to decode
the request. It's expecting one of the following in the Content-Type
header:

  * application/x-www-form-urlencoded
  * multipart/form-data; boundary=[your boundary here]
  * application/json
  * text/json


Since none of those are set (possibly something else, possibly
nothing set at all?) then Taffy doesn't know what to do.

You can use a proxy like Charles <http://www.charlesproxy.com/> to
see the raw contents of the HTTP request you're sending. That will be
very helpful in debugging.

Adam

Jean-Bernard van Zuylen wrote:


Hi,

I'm trying use to upload file functionality from Taffy 1.1 but can't
make it work.

I followed what is written on the Wiki about this topic but I'm always
getting the following HTTP error:

400 You must specify a content-type. Aborting request.

I've been looking in the file api.cfc but couldn't find any code
handling the content type multipart/form-data.

Jean-Bernard



Jean-Bernard van Zuylen wrote:

You must specify a content-type

Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>

July 11, 2012 9:15 AM
Hi,

I'm trying use to upload file functionality from Taffy 1.1 but can't
make it work.

I followed what is written on the Wiki about this topic but I'm
always getting the following HTTP error:

400 You must specify a content-type. Aborting request.

I've been looking in the file api.cfc but couldn't find any code
handling the content type multipart/form-data.

Jean-Bernard


July 13, 2012 8:04 PM

Jean-Bernard van Zuylen

unread,
Jul 18, 2012, 10:58:13 AM7/18/12
to taffy...@googlegroups.com
Hi Adam,

Since I have both ACF and Railo installed on my machine (we are migrating from ACF to Railo), I've run your test on both servers.

On ACF, GetHTTPRequestData().content returns an empty value when the content type is multipart/form-data (apparently since ACF 8 to avoid memory issues by keeping the uploaded file in memory). The length of the request body is 0 and the content-type is not checked in Taffy.
Railo, on the contrary, is returning full the request body and the content type is checked. Adding a IF-logic that does nothing as you suggest should indeed fix the problem.

On both servers the form fields from the multi-part form are correctly put into form scope.

JB


Le samedi 14 juillet 2012 16:03:01 UTC+2, Adam Tuttle a écrit :
One additional thing I'll point out is that, as long as your app server (whether it's ACF, Railo, OpenBD, Smith, or something else) puts the form fields from the multi-part form into the form scope, they should all be picked up. The one possibility I see is that on non-ACF app servers the content-type may trigger the error you're talking about. If that's the case we can probably add a branch to the IF-logic that does nothing except NOT throw the error.

Adam

Adam Tuttle wrote:

Ok, I pushed the new test to the *develop* branch on github. It's at
the bottom of TestCore.cfc.

To run the tests, first open /taffy/tests/ in your browser to
initialize the api, then open /taffy/tests/tests/ to run the mxunit
test suite. Of course, requires you have an /mxunit mapping or have it
in your web root.

And if you're running Railo on Tomcat, you're going to want to add the
additional servlet mapping for /taffy/tests/index.cfm/* to web.xml.

Let me know how you make out.

Adam


July 13, 2012 7:23 PM
Very odd indeed. I'll have to code up a test for this to verify that
it's working. Been slammed at work this week. Might be able to get to
it this weekend.

I wonder if this is a Railo-specific issue. It's possible that under
the hood ACF sees "multipart/form-data" and converts it to
application/x-www-form-urlencoded  (in memory, where we're looking)...

Anyway, I'll see about getting a test put together to (a) verify my
install is still working, and (b) have you try it out on Railo. :)

Adam

Jean-Bernard van Zuylen wrote:
Jean-Bernard van Zuylen <mailto:jbvanzuylen@hotmail.com>
Jean-Bernard van Zuylen <mailto:jbvanzuylen@hotmail.com>

Adam Tuttle

unread,
Jul 18, 2012, 11:44:03 AM7/18/12
to taffy...@googlegroups.com
Pushed the change to the develop branch. Let me know if that fixes it!


Adam

Jean-Bernard van Zuylen wrote:

Hi Adam,

Since I have both ACF and Railo installed on my machine (we are
migrating from ACF to Railo), I've run your test on both servers.

On ACF, GetHTTPRequestData().content returns an empty value when the
content type is multipart/form-data (apparently since ACF 8 to avoid
memory issues by keeping the uploaded file in memory). The length of
the request body is 0 and the content-type is not checked in Taffy.
Railo, on the contrary, is returning full the request body and the
content type is checked. Adding a IF-logic that does nothing as you
suggest should indeed fix the problem.

On both servers the form fields from the multi-part form are correctly
put into form scope.

JB

Le samedi 14 juillet 2012 16:03:01 UTC+2, Adam Tuttle a écrit :

    One additional thing I'll point out is that, as long as your app
    server (whether it's ACF, Railo, OpenBD, Smith, or something else)
    puts the form fields from the multi-part form into the form scope,
    they should all be picked up

    The one possibility I see is that on non-ACF app servers the
    content-type may trigger the error you're talking about. If that's
    the case we can probably add a branch to the IF-logic that does
    nothing except NOT throw the error.

    Adam

    Adam Tuttle wrote:


    Ok, I pushed the new test to the *develop* branch on github. It's at
    the bottom of TestCore.cfc.

    To run the tests, first open /taffy/tests/ in your browser to
    initialize the api, then open /taffy/tests/tests/ to run the mxunit
    test suite. Of course, requires you have an /mxunit mapping or
    have it
    in your web root.

    And if you're running Railo on Tomcat, you're going to want to
    add the
    additional servlet mapping for /taffy/tests/index.cfm/* to web.xml.

    Let me know how you make out.

    Adam



    Adam Tuttle <mailto:ad...@fusiongrokker.com>
    <mailto:ad...@fusiongrokker.com>

    July 13, 2012 7:23 PM
    Very odd indeed. I'll have to code up a test for this to verify
    that
    it's working. Been slammed at work this week. Might be able to
    get to
    it this weekend.

    I wonder if this is a Railo-specific issue. It's possible that
    under
    the hood ACF sees "multipart/form-data" and converts it to
    application/x-www-form-urlencoded (in memory, where we're
    looking)...

    Anyway, I'll see about getting a test put together to (a) verify my
    install is still working, and (b) have you try it out on Railo. :)

    Adam

    Jean-Bernard van Zuylen wrote:
    Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>
    <mailto:jbvan...@hotmail.com>
    Adam Tuttle <mailto:ad...@fusiongrokker.com>
    <mailto:ad...@fusiongrokker.com>
    Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>
    <mailto:jbvan...@hotmail.com>

    July 11, 2012 9:15 AM
    Hi,

    I'm trying use to upload file functionality from Taffy 1.1 but
    can't
    make it work.

    I followed what is written on the Wiki about this topic but I'm
    always getting the following HTTP error:

    400 You must specify a content-type. Aborting request.

    I've been looking in the file api.cfc but couldn't find any code
    handling the content type multipart/form-data.

    Jean-Bernard





    Adam Tuttle <mailto:ad...@fusiongrokker.com>

    July 13, 2012 8:04 PM
    Ok, I pushed the new test to the *develop* branch on github. It's
    at the bottom of TestCore.cfc.

    To run the tests, first open /taffy/tests/ in your browser to
    initialize the api, then open /taffy/tests/tests/ to run the
    mxunit test suite. Of course, requires you have an /mxunit
    mapping or have it in your web root.

    And if you're running Railo on Tomcat, you're going to want to
    add the additional servlet mapping for /taffy/tests/index.cfm/*
    to web.xml.

    Let me know how you make out.

    Adam

    Adam Tuttle <mailto:ad...@fusiongrokker.com>

    July 13, 2012 7:23 PM
    Very odd indeed. I'll have to code up a test for this to verify
    that it's working. Been slammed at work this week. Might be able
    to get to it this weekend.

    I wonder if this is a Railo-specific issue. It's possible that
    under the hood ACF sees "multipart/form-data" and converts it to
    application/x-www-form-urlencoded (in memory, where we're looking)...

    Anyway, I'll see about getting a test put together to (a) verify
    my install is still working, and (b) have you try it out on Railo. :)

    Adam

    Jean-Bernard van Zuylen wrote:
    Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>
    Adam Tuttle <mailto:ad...@fusiongrokker.com>
    Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>

Jean-Bernard van Zuylen van Nyevelt

unread,
Jul 18, 2012, 12:13:52 PM7/18/12
to taffy...@googlegroups.com
Hi Adam,

I just tested your change but now getting the following error:

{"DETAIL":"","ERROR":"key [QUERYSTRING] doesn't exist in struct (keys:HEADERS,BODY,VERB,MATCHINGREGEX,URIFORMAT,METHOD,MATCHDETAILS,CONTENTTYPE,URI)","TAGCONTEXT":"D:\\Railo\\tomcat\\webapps\\ROOT\\taffy\\core\\api.cfc [Line 377]"}

JB


Date: Wed, 18 Jul 2012 11:44:03 -0400
From: ad...@fusiongrokker.com
To: taffy...@googlegroups.com
Subject: Re: Problems uploading files

Adam Tuttle

unread,
Jul 18, 2012, 12:19:58 PM7/18/12
to taffy...@googlegroups.com
Ok, just pushed another change that should fix that.

Thanks,
Adam

Jean-Bernard van Zuylen van Nyevelt wrote:
>
> Hi Adam,
>
> I just tested your change but now getting the following error:
>
> {"DETAIL":"","ERROR":"key [QUERYSTRING] doesn't exist in struct
> (keys:HEADERS,BODY,VERB,MATCHINGREGEX,URIFORMAT,METHOD,MATCHDETAILS,CONTENTTYPE,URI)","TAGCONTEXT":"D:\\Railo\\tomcat\\webapps\\ROOT\\taffy\\core\\api.cfc
>
> [Line 377]"}
>
> JB
>
> ------------------------------------------------------------------------

Jean-Bernard van Zuylen

unread,
Jul 19, 2012, 4:26:47 AM7/19/12
to taffy...@googlegroups.com
Hi Adam,

The test is now OK.

I will now integrate this in my application.

Thanks!

JB
>             Jean-Bernard van Zuylen <mailto:jbvanzuylen@hotmail.com>
> <mailto:jbvanzuylen@hotmail.com>
>             Jean-Bernard van Zuylen <mailto:jbvanzuylen@hotmail.com>
> <mailto:jbvanzuylen@hotmail.com>
>         Jean-Bernard van Zuylen <mailto:jbvanzuylen@hotmail.com>
>         Jean-Bernard van Zuylen <mailto:jbvanzuylen@hotmail.com>

Tim Vanderlois

unread,
Jun 18, 2015, 3:47:08 PM6/18/15
to taffy...@googlegroups.com
I realize this is an old post, but my file is saved with the CF temp file name through the api? Weird I know - but a simple test page (outside the api) does not use the CF temp file name... any thoughts?

<cfhttp url="http://99.99.99.99/safetyDataSheets/api/index.cfm/documentImage/" method="post" result="result">
     <cfhttpparam type="file" name="image" file="#form.fileInput#" />
</cfhttp>

<cffile  action="upload" 
            destination="#expandPath('/root/docImages/')#"
            fileField="image"
            nameConflict="overwrite"
            result="local.uploadResult"
            />
>             Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>
> <mailto:jbvan...@hotmail.com>
>             Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>
> <mailto:jbvan...@hotmail.com>
>         Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>
>         Jean-Bernard van Zuylen <mailto:jbvan...@hotmail.com>
Reply all
Reply to author
Forward
0 new messages