-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathquickAcsPhoto.js
More file actions
49 lines (47 loc) · 1.22 KB
/
quickAcsPhoto.js
File metadata and controls
49 lines (47 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function uploadPhoto( _source, _callback) {
var onSuccess = function(e){
if(e.media){
Cloud.Photos.create({
photo: e.media
}, function (e) {
if (e.success) {
var photo = e.photos[0];
alert('Success:\\n' +
'id: ' + photo.id + '\\n' +
'filename: ' + photo.filename + '\\n' +
'size: ' + photo.size,
'updated_at: ' + photo.updated_at);
} else {
alert('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));
}
_callback && _callback(e);
});
}
}
switch(_source){
case "CAMERA":
Ti.Media.showCamera({
animated: true,
allowEditing: true,
autohide: true,
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
success: onSuccess,
error: function(e){ alert('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));}
});
break;
case "GALLERY":
Ti.Media.openPhotoGallery({
animated: true,
allowEditing: true,
autohide: true,
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
success: onSuccess,
error: function(e){ alert('Error:\\n' +
((e.error && e.message) || JSON.stringify(e)));}
});
break;
default:
}
}