No custom headers for FileReference.upload. Why?
I got excited when I learned that YouTube opened their API for third party developers. This would enable me to - for example - create a nifty AIR widget to quickly upload videos to my YouTube account. Drag-and-drop a video file onto the AIR app and have the uploading done in the background. Cool!
So I took off, did the authentication stuff with the ClientLogin API so I was able to login into my YouTube account with Flash.
Next: add uploading functionality. Again, the docs are clear and I’m halfway done when I re-read the URLRequest.requestHeaders documentation, only to find out that custom headers (required for the YouTube upload to succeed) are not supported by FileReference.upload!
So much for my YouTube upload AIR widget…
Adobe, PLEASE consider removing this restriction from a future Flash player. Or please tell me why this restriction is imposed on the upload method, as I fail to see why we shouldn’t be allowed to create our own POST request headers for the upload method.

March 27th, 2008 at 0:13
Isn’t this the kind of thing you need..?
var request:URLRequest = new URLRequest(_uploadUrl + “?filename=” + id);
request.method = URLRequestMethod.POST;
_f.upload(request, “image”, false);
March 27th, 2008 at 9:45
@Dave: Thanks for your feedback, but unfortunately, that doesn’t do the trick, as you really need control over the actual HTTP headers when the request is sent.
So, adding variables and all woks fine, it is the requestHeaders where things break.
It is ironic, actual uploading to YouTube works (yeehah!), but the file is rejected afterwards, beause the YT server cannot find the correct data it is ecpecting in the request headers. Sigh…
March 27th, 2008 at 10:03
What if you work with an proxy php file that, only when you upload you do a call to that file, php sends the custom header, and passes the result back to flash. I know you probably want to do this all in Flash without the need of any other languages, but it could solve your problems
Cheers,
Sid
March 27th, 2008 at 10:11
Maybee you this is your answer: http://framework.zend.com/download/gdata
Good luck and keep us posted on any developemnts!
Sid
March 28th, 2008 at 12:45
@Sidney - yeah a proxy could certainly do the trick, but I wanted to create a standalone app. I’ll have a look and see if using a proxy means that the actual upload will go ‘through’ the proxy. If not, this could be a solution, else my server would soon die if many people start using such an app (due to bandwidth limitations).
April 2nd, 2008 at 4:31
@Dave:
I think Martijn need this:
var request:URLRequest = new URLRequest(_uploadUrl + “?filename=†+ id);
request.method = URLRequestMethod.POST;
request.setHeader(”headerName”, “headerValue”);
// or request.addHeader(”headerName”, “appendedValue”);
_f.upload(request, “imageâ€, false);
but adobe not support this yet…
April 2nd, 2008 at 14:47
@isxylands - yes, that is sort of what you need, but like I said, request headers are simply ignored by the Flash Player when they are added to a FileReference.upload request. Bummer.
April 6th, 2008 at 13:25
seems to be a similar issue as the filereference issue for mac users. I’m not sure if there’s a link, but I hope Adobe starts urgent with improving the filereference possibility. That would be necessary to be able to build professional cross platform web applications.
April 7th, 2008 at 10:26
Hi Martijn,
Did some research on this; Why not use the Socket Class? That way you can read/write anything to a specific port. And also write the custom header needed for this google api auth. Try looking into that.
Hope this helps,
Sidney de Koning
April 22nd, 2008 at 16:26
Hm, intersting - not sure if I can make a regular POST requist using Sockets though. Thanks for your feedback!