send files from google drive to dropbox with google app scripts
I've been searching how to do this, but i didn't find anything. After a while, i came up with the script i'll post as an answer. I'm posting this for myself and anyone who might find it useful.
You'll need to get a dropbox access token, that can be obtained after creating a dropbox app.
function send2dropbox(file) {
var dropboxTOKEN = 'XXXxxx';
var path = '/somePath/' + file.getName();
var dropboxurl = 'https://api.dropboxapi.com/2/files/save_url';
var fileurl = 'https://drive.google.com/uc?export=download&id=' + file.getId();
var headers = {
'Authorization': 'Bearer ' + dropboxTOKEN,
'Content-Type': 'application/json'
};
var payload = {
"path": path,
"url": fileurl
}
var options = {
method: 'POST',
headers: headers,
payload: JSON.stringify(payload)
};
var response = UrlFetchApp.fetch(dropboxurl, options);
return response;
}
你可以在这里找到一个例子
链接地址: http://www.djcxy.com/p/69086.html上一篇: 从NodeJS上传上传到Dropbox