Reputation: 13733
I'm trying to use Appcelerator Titanium with Parse.com service. Since there is no library for Titanium, I'm using the rest API of Parse.
A Class object on Parse can have a field of type "File". How do I post a file (blob object) to that field?
Upvotes: 0
Views: 168
Reputation: 33345
Here is a starter template application for using Parse with Appcelerator
https://github.com/aaronksaunders/parse-starter-appC
it wraps the parse API in a appcelerator alloy sync adapter
A helper method with allow you to upload the file and associate it with a specific object called a FileHelper
. This FileHelper
object will provide access to the image
var parseService = require('parseREST');
parseService.init();
file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "iTunesConnect.png");
var blob = file.read();
parseService.uploadFile("image/jpeg", "iTunesConnect.png", blob).then(function(_results) {
return parseService.createObject('FileHelper', {
"nameKey" : _results.response.name,
"fileData" : {
"name" : _results.response.name,
"__type" : "File"
}
}).then(function(_results2) {
console.log("FileHelper Object: " + JSON.stringify(_results2));
},function(_error)
console.log("ERROR: " + JSON.stringify(_error));
});
The results should look something like this:
{
"createdAt": "2015-05-11T15:30:52.004Z",
"objectId": "yLPdeXDinq"
}
Upvotes: 1