Skip to content

Commit

Permalink
add setPermissions()
Browse files Browse the repository at this point in the history
  • Loading branch information
behoyh committed Apr 11, 2022
1 parent 431cc59 commit ec9a69f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var upload = (client, file) => {
auth: client,
resource: {
name: file.name,
parents: []
mimeType: file.type
},
media: {
mimeType: file.type,
Expand All @@ -55,6 +55,26 @@ var upload = (client, file) => {
});
}

var setPermissions = (client, data) => {
drive.permissions.create({
auth: client,
fileId: data.id,
supportsAllDrives: true,
supportsTeamDrives: true,
resource: {
'type': 'anyone',
'role': 'reader',
},
fields: 'id',
}, function (err, res) {
if (err) {
console.error(err);
} else {
console.log('Permission ID: ', res.id)
}
});
}

var get = (client, fileId, callback) => {
drive.files.get({
auth: client,
Expand Down Expand Up @@ -104,6 +124,7 @@ class ghostGoogleDrive extends StorageBase {
.then(data => {
console.log(data);
resolve('/content/images/' + data.id + '.' + data.fileExtension);
setPermissions(client, data);
});
});
});
Expand Down

0 comments on commit ec9a69f

Please sign in to comment.