Bearer Tokens
A Bearer Token
is set in the Authorization
header of every Inline Action HTTP Request. For example:
POST /rsvp?eventId=123 HTTP/1.1
Host: events-organizer.com
Authorization: Bearer AbCdEf123456
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/1.0 (KHTML, like Gecko; Gmail Actions)
$ionicLoading.show();
若遇到莫名其妙的錯(cuò)誤,檢查 controller 傳入的function 參數(shù)是否正確淮阐!或者檢查依賴注入是否正確!js包是否在index.html中引入唐全!
- 圖片上傳到服務(wù)器
1.1 $cordovaCamera 和 $cordovaImagePicker
$cordovaImagePicker 獲得的圖片地址格式如下:
file:///private/var/mobile/Containers/Data/Application/E0D48F33-105F-41B7-A335-3B82312F2C8E/tmp/
這樣的格式 不能直接上傳到服務(wù)器(試了很多辦法,沒成功截珍,若可以請(qǐng)告知Uǘ伞)
最后通過(guò)第三方庫(kù)解決 https://github.com/nolanlawson/blob-util#imgSrcToDataURL
npm 安裝插件的適合切記裝到 www目錄下!要不然加載不到j(luò)s包偷拔!
把url 轉(zhuǎn)成 DataURL
blobUtil.imgSrcToDataURL($scope.images_list[i]).then(function (dataURL) { // success var path = $scope.images_list[0].split('/'), name = path[path.length - 1], base64 = dataURL.replace(/^[ ^,]+,/, ''), file = new AV.File(name, { base64: base64 }); return file.save();}).then(function(response){ console.log(response);},function(err){ console.log(err);});