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();
若遇到莫名其妙的错误,检查 controller 传入的function 参数是否正确!或者检查依赖注入是否正确!js包是否在index.html中引入!
- 图片上传到服务器
1.1 $cordovaCamera 和 $cordovaImagePicker
$cordovaImagePicker 获得的图片地址格式如下:
file:///private/var/mobile/Containers/Data/Application/E0D48F33-105F-41B7-A335-3B82312F2C8E/tmp/
这样的格式 不能直接上传到服务器(试了很多办法,没成功,若可以请告知!)
最后通过第三方库解决 https://github.com/nolanlawson/blob-util#imgSrcToDataURL
npm 安装插件的适合切记装到 www目录下!要不然加载不到js包!
把url 转成 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);});