admin管理员组

文章数量:1322686

i have to add the header access token

  $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) {
                }
            }};

And my header access token is

{ headers: { 'Authorization': 'Bearer ' + $scope.access_token } }

and i need to add this to the url or the api that i am trying to call

i have to add the header access token

  $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) {
                }
            }};

And my header access token is

{ headers: { 'Authorization': 'Bearer ' + $scope.access_token } }

and i need to add this to the url or the api that i am trying to call

Share Improve this question asked May 11, 2017 at 7:22 Omkar DixitOmkar Dixit 7661 gold badge9 silver badges20 bronze badges 1
  • can you tried headers: { 'Authorization': 'Bearer ' + $scope.access_token } – Ranjeet Singh Commented May 11, 2017 at 7:38
Add a ment  | 

2 Answers 2

Reset to default 7

You can add the header in the headers options of your dropzone object. Check the headers attribute in the options in the following example:

    $("#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},          
    });
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  }
  }

本文标签: javascripthow to include the header access token to the Dropzone configStack Overflow