| xqd
@@ -53,19 +53,27 @@
|
|
|
});
|
|
|
return deferred.promise;
|
|
|
},
|
|
|
- uploadFiles: function (imageUri) {//通用上传
|
|
|
+ uploadFiles: function (imageUri,type) {//通用上传,type:1图片,2视频
|
|
|
var deferred = $q.defer();
|
|
|
if (imageUri) {
|
|
|
var uploadOptions = new FileUploadOptions();
|
|
|
- uploadOptions.fileKey = "store";
|
|
|
- uploadOptions.fileName = "store.jpg";
|
|
|
- uploadOptions.mimeType = "image/jpeg";
|
|
|
+ if (type==1) {//图片
|
|
|
+ uploadOptions.fileKey = "picture";
|
|
|
+ uploadOptions.fileName = "picture.jpg";
|
|
|
+ uploadOptions.mimeType = "image/jpeg";
|
|
|
+ uploadOptions.params = { tag: "picture" };
|
|
|
+ }
|
|
|
+ if (type==2) {//视频
|
|
|
+ uploadOptions.fileKey = "video";
|
|
|
+ uploadOptions.fileName = "video.mp4";
|
|
|
+ uploadOptions.mimeType = "video/mpeg";
|
|
|
+ uploadOptions.params = { tag: "video" };
|
|
|
+ }
|
|
|
uploadOptions.httpMethod = 'post';
|
|
|
uploadOptions.chunkedMode = true;
|
|
|
var token = 'Bearer ' + localStorage['token'];
|
|
|
uploadOptions.headers = { "Authorization": token };
|
|
|
var ft = new FileTransfer();
|
|
|
- uploadOptions.params = { tag: "picture" };
|
|
|
ft.upload(imageUri, encodeURI(config.server + "api/attachment/upload"), function (sucess) {
|
|
|
deferred.resolve(sucess);
|
|
|
// alert('上传成功' + JSON.stringify(sucess));
|