upload file to dropBox using /files_put javascript

前端 未结 2 1037
一向
一向 2020-12-21 01:56

Is it possible to upload a local file to dropbox using http put method ? i am uploading a file but it is without body ? ( \"bytes\": 0 )

how can i add a content

相关标签:
2条回答
  • 2020-12-21 02:38

    I don't see anywhere in your HTTP call where you're actually passing a body. It seems like you're making an empty PUT request?

    (Or maybe there's just something here about AngularJS that I don't understand, and you're adding a body somewhere else?)

    0 讨论(0)
  • 2020-12-21 02:43

    @smarx : i was making an empty HTTP PUT request, and i ended up by solving my issue this way:

    $scope.uploadHtmlFile = function() {
        var data = "This is a file upload test ";
    
        $http({
            method: 'PUT',
            url: 'https://api-content.dropbox.com/1/files_put/dropbox/test.html?access_token=' + localStorage.getItem('accessToken'),
            data: data
        }).success(function(data, status, headers, config) {
            console.log(data);
            console.log('file uploaded successfully');
        }).error(function(data, status, headers, config) {
    
        });
    }
    

    thanks for your feedback !

    0 讨论(0)
提交回复
热议问题