-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFiles.js
More file actions
38 lines (32 loc) · 1.03 KB
/
Files.js
File metadata and controls
38 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function downloadPDF(fileId) {
var url = 'https://api.box.com/2.0/files/' + fileId + '/content/';
var response = UrlFetchApp.fetch(url, {
contentType: 'application/json',
headers: {
'Authorization': 'Bearer ' + getBoxService_().getAccessToken()
}
});
return response.getBlob();
}
function downloadTextRepresentation(urlTemplate) {
var token = getBoxService_().getAccessToken();
var response = UrlFetchApp.fetch(urlTemplate, {
contentType: 'application/json',
headers: {
'Authorization': 'Bearer ' + token
}
});
Logger.log(response.getContentText());
return response.getContentText();
}
function getFileInformation(fileId) {
var url = 'https://api.box.com/2.0/files/' + fileId + '?fields=representations,name,created_at,created_by';
var response = UrlFetchApp.fetch(url, {
contentType: 'application/json',
headers: {
'x-rep-hints': '[extracted_text]',
'Authorization': 'Bearer ' + getBoxService_().getAccessToken()
}
});
return JSON.parse(response.getContentText());
}