我必须添加标头访问令牌
$scope.dropzoneConfig = {
'options': { // passed into the Dropzone constructor
'url': 'SOME API URL' + $scope.SOME_ID
},
'eventHandlers': {
'sending': function (file, xhr, formData) {
},
'success': function (file, response) {
}
}};
我的标头访问令牌是
{ headers: { 'Authorization': 'Bearer ' + $scope.access_token } }
我需要将其添加到我要调用的网址或api
答案 0 :(得分:1)
您可以在headers options
对象的dropzone
中添加标题。
检查以下示例中选项中的headers
属性:
$("#dropzone").dropzone({
autoProcessQueue: false,
url: "/content",
maxFiles: 1,
clickable: true,
acceptedFiles: ".png,.jpg,.jpeg",
addRemoveLinks: true,
maxFilesize: 10, //MB
headers:{"Authorization":'Bearer ' + $scope.access_token},
});
答案 1 :(得分:0)
const getUploadParams = ({ file, meta }) => {
const body = new FormData();
let headers;
UserTool.getToken((token) => {
headers= { Authorization: `Bearer ${token}` }
body.append('file', file, file.name)
});
return { url: UrlConfig.tileset.uploadUrl, body, headers }
}