How do i upload pictures i take from my fuse app to a remote server
Here is an example with fetch
:
<App>
<JavaScript>
var Camera = require('FuseJS/Camera');
var ImageTools = require('FuseJS/ImageTools');
Camera.takePicture(150, 150).then(function(image) {
return ImageTools.getBufferFromImage(image).then(function(buffer) {
return fetch('http://<your_uri>', { method: "POST", body: buffer });
});
}).then(function(response) {
console.log("Got response");
}).catch(function(e){
console.log("Error");
console.log(e);
});
</JavaScript>
</App>
and this an example with XMLHttpRequest
:
<App>
<JavaScript>
var Camera = require('FuseJS/Camera');
var ImageTools = require('FuseJS/ImageTools');
Camera.takePicture(150, 150).then(function(image) {
return ImageTools.getBufferFromImage(image).then(function(buffer) {
return new Promise(function(resolve, reject) {
try {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
resolve(xhr.response);
};
xhr.onerror = function(e) {
reject(e);
}
xhr.open("POST", "http://<your_uri>");
xhr.send(buffer);
} catch (e) {
reject(e);
}
});
});
}).then(function(response) {
console.log("Got response");
}).catch(function(e){
console.log("Error");
console.log(e);
});
</JavaScript>
</App>
Nice example. I would love to ask…In case I want to use a photo already in the mobile phone, How do I do it.
I would love to use both versions and how do i POST it as a base64encoded string …
Regards
quincykwende@gmail.com wrote:
Nice example. I would love to ask…In case I want to use a photo already in the mobile phone, How do I do it.
I would love to use both versions and how do i POST it as a base64encoded string …Regards
Please post separate threads when asking new questions. For this you can use the CameraRoll and ImageTools.
Thanks
Anders Bondehagen wrote:
quincykwende@gmail.com wrote:
Nice example. I would love to ask…In case I want to use a photo already in the mobile phone, How do I do it.
I would love to use both versions and how do i POST it as a base64encoded string …Regards
Please post separate threads when asking new questions. For this you can use the CameraRoll and ImageTools.