Page 1 of 1

File upload working but unreadable

Posted: Wed Aug 21, 2013 7:34 am
by Bob Fludder

Hi. I'm trying to upload a photo taken by the camera to sharefile. I've been digging through all the documents etc i can find including this thread: https://getsatisfaction.com/apperyio/...
and as a result I'm able to upload a file. The problem is the file is unusable. When I try to open it with windows photo viewer it says its damaged corrupted or too large..
The javascript I'm using is and you can see based on the one in the link above (UploadfromCamera):
function FileUpload() {

var serverUrl = localStorage.getItem('locURL') + '&filename=' + encodeURIComponent(getFileName());
var imageDataBase64 = localStorage.getItem('locImage');
var rawdata = Base64.decode(imageDataBase64);

alert(serverUrl);

$.ajax({
type: "POST",
beforeSend: function(request) {
request.setRequestHeader("Content-Type", "image/jpeg");
},

url: serverUrl,
data: rawdata,
processData: false,
contentType: false,
success: function(data) {

alert("Upload successful");
},
error: function(data) {
// do something in case of an error...
alert(data.responseText);
}
});
}

Any ideas will be greatly appreciated.


File upload working but unreadable

Posted: Wed Aug 21, 2013 8:28 am
by Kateryna Grynko

Hi Bob,

Please take a look at here: http://docs.phonegap.com/en/2.4.0/cor...


File upload working but unreadable

Posted: Wed Aug 21, 2013 10:12 am
by Bob Fludder

Yes. Thought about that. It means I need to change the camera settings to output a fileuri and use that as input for the transfer rather than the raw image doesn't it?


File upload working but unreadable

Posted: Wed Aug 21, 2013 12:02 pm
by Bob Fludder

Right. Have tried this but am getting a similar result. I can see some "additional" data inside the image: --+++++
Content-Disposition: form-data; name="file"; filename="image.jpg"
Content-Type: image/jpeg
I know this is outside your support but any ideas would be great.
Thanks


File upload working but unreadable

Posted: Wed Aug 21, 2013 1:19 pm
by Kateryna Grynko

Bob,

You correctly reconfigured Camera service to return the name of received file. Now you would need to read it from the device file system to buffer and pass it on to our backend as usual file upload, NOT to the collection, namely the file. It was already discussed here in the forum.