I am uploading a picture to cloud using Appcelerator Cloud Services and want to retrieve it back in all sizes. Uploading is working fine but I am not getting the photo back. I am getting the urls
in JSON response:
Here is my code:
Cloud.Photos.show({
photo_id: pid
}, function (e) {
if (e.success) {
var photo = e.photos[0];
waitDialog.hide();
alert('Success:\n' +
'id: ' + photo.id + '\n' +
'filename: ' + photo.filename + '\n' +
'updated_at: ' + photo.updated_at + '\n' +
'urls: ' + photo.urls);
alert(photo.urls.square);
var image2 = photo.urls.square.toImage();
var squareImage = Ti.UI.createImageView({
top: "10dp",
left: "10dp",
image: image2,
height: Titanium.UI.SIZE,
width: Titanium.UI.SIZE
});
$.index.add(squareImage);
} else {
alert('Error:\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
and I am getting a JSON response like this (This is not original, as I am testing it in device)
{
"meta": {
"status":"ok",
"code":200,
"method_name":"showPhoto"
},
"response": {
"photos": [
{
"id":"4d51d4186f70952d4c000006",
"filename":"photo.jpg",
"size":584344,
"collection_name":"default",
"md5":"589b8ad43ed20bf8e622d719642bc939",
"created_at":"2011-02-08T23:39:04+0000",
"updated_at":"2011-02-08T23:39:08+0000",
"processed":true,
"content_type":"image/jpeg",
"urls": {
"square":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_square.jpg",
"thumb":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_thumb.jpg",
"small":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_small.jpg",
"medium_500":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_medium_500.jpg",
"medium_640":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_medium_640.jpg",
"large":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_large.jpg",
"original":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_original.jpg"
}
}
]
}
}
I want to get all images from the urls
.
Do I need to parse it or anything else I need to do? Can anyone tell me how to do this?
Thanks :)