我正在尝试使用以下代码将文件上传到Dropbox。文件已成功上传到Dropbox,但大小已超过0个字节。
我现在正计划上传microsoft word和pdf文件。
$scope.uploadHtmlFile = function($files) {
var data = $files;
$http({
method: 'PUT',
url: 'https://api-content.dropbox.com/1/files_put/dropbox/' + $files[0].name + '?access_token=TOKEN',
data: data
}).success(function(data, status, headers, config) {
console.log(data);
console.log('file uploaded successfully');
}).error(function(data, status, headers, config) {
console.log('error : ' + data);
console.log('erro file uploaded successfully');
});
}
答案 0 :(得分:0)
$ files是一个数组对象,文件将使用$ files [0]引用。
$scope.uploadHtmlFile = function($files) {
var data = $files[0];
$http({
method: 'PUT',
url: 'https://api-content.dropbox.com/1/files_put/dropbox/' + $files[0].name + '?access_token=TOKEN',
data: data
}).success(function(data, status, headers, config) {
console.log(data);
console.log('file uploaded successfully');
}).error(function(data, status, headers, config) {
console.log('error : ' + data);
console.log('erro file uploaded successfully');
});
}