diff --git a/index.js b/index.js index 5d99982..483b0a8 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ var upload = (client, file) => { auth: client, resource: { name: file.name, - parents: [] + mimeType: file.type }, media: { mimeType: file.type, @@ -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, @@ -104,6 +124,7 @@ class ghostGoogleDrive extends StorageBase { .then(data => { console.log(data); resolve('/content/images/' + data.id + '.' + data.fileExtension); + setPermissions(client, data); }); }); });