사진을 올리면 프로세싱 단계를 거치기 때문에 사진 url을 바로 가져오지 못하는데요.
비동기 처리 하지 않고 바로 가져오게 하는 옵션이 있더군요.
혹시 저처럼 헤매시는 분이 계실까봐 기록해 둡니다.
'photo_sync_sizes[]' : "preview"
저는 thumbnail 과 preview 두개의 사이즈를 추가로 만들었는데요.
업로드 하고 바로 썸네일 url을 가져오기 위해 위의 옵션을 추가 햇습니다.
Cloud.Photos.create({
photo : upImage,
title : 'test',
photo_sizes : { "thumbnail" : "120x120#", "preview" : "640x300#" },
'photo_sync_sizes[]' : "preview",
content : '',
custom_fields : { "width" : width, "height" : height }
}, function (e) {
if (e.success) {
var photo = e.photos[0];
Ti.API.info("photo result", JSON.stringify(photo));
alert('Success:\n' +
'id: ' + photo.id + '\n' +
'filename: ' + photo.filename + '\n' +
'size: ' + photo.urls,
'updated_at: ' + photo.updated_at);
} else {
alert('Error:\n' +
((e.error && e.message) || JSON.stringify(e)));
}
});
로그를 찍어보면 잘 가져옵니다.
photo result {"id":"55acbae47b91ea0b84004fc7","filename":"01437383394.jpeg","size":501062,"md5":"a33761b91f18cf7ced0d6ee59a5541c8","created_at":"2015-07-20T09:09:56+0000","updated_
at":"2015-07-20T09:09:56+0000","processed":false,"title":"test","urls":{"preview":"https://s3-us-west-1.amazonaws.com/storage-platform.cloud.appcelerator.com/PGRtSIkhT8RDb0ugEW8UJOlombOcDxDm/photos/41/c8/55acbae4
7b91ea0b84004fc8/01437383394_preview.jpeg","original":"https://s3-us-west-1.amazonaws.com/storage-platform.cloud.appcelerator.com/PGRtSIkhT8RDb0ugEW8UJOlombOcDxDm/photos/41/c8/55acbae47b91ea0b84004fc8/01437383394
_original.jpeg"},"content_type":"image/jpeg","user_id":"--","custom_fields":{"width":800,"height":533}}