I'm using the Forge file module to try and upload an image from the gallery. Forge is running on Android 2.3 and the image selection capture bit works fine. But when I try to send the file with Request.Ajax() I get a forge exception.
I've dumped the output from the Catalyst log below
Request URL:forge.request.ajax
Request Method:undefined
Status Code:400 error
{ url: 'http://example.com/',
username: null,
password: null,
data: null,
headers: { Accept: '*/*', 'Content-Type': 'image/jpg' },
timeout: 60000,
type: 'POST',
boundary: null,
files:
[ { uri: 'content://media/external/images/media/212#Intent;end',
name: 'Image',
height: 500,
width: 500 } ],
fileUploadMethod: 'raw' } // <- got this from a blog post,
And this is what I get in return
{ type: 'UNEXPECTED_FAILURE',
message: 'Forge Java error: FileNotFoundException: http://example.com/' }
I've checked the server side and confirmed there is no problem there (Made a test script that posts there). The app posts to the server if I remove the file attach calls.
I've looked at the sample code posted here but it seems to be using the old API and I can't find some of the methods - https://github.com/trigger-corp/photo-log/blob/master/photolog.js
Am I doing anything wrong in the file call?
There are no obvious problems with your Catalyst output: the FileNotFoundException
just indicated something went wrong on the server side. In this case, I guess example.com wasn't expecting a multipart encoded POST.
We pushed some code live yesterday which makes our request.ajax error messages much clearer: I'd suggest you rebuild and re-run your app and see if you can tell what the server-side problem is.