-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing objects from Google Drive #92
Comments
Great and thankful!! A) will bring this into main documentation B) will add
this to future improvements, for sure we can plan for automatic decoration
of the URLs needed. Give me a few days to think about the “where”
El El mar, 16 de oct. de 2018 a las 17:07, Mark Sandford <
[email protected]> escribió:
IMI can pull objects directly from a Google Drive with the following
caveats/notes:
1. The URI must be constructed using an API key to provide a direct
download link, since shareable link points to a viewer, not the object.
2. Files must be shared correctly.
3. Google Team Drive does not allow sharing on folder level, only on a
file by file basis.
If it's useful, below is a Google Code snippet intended to be run in a
Google Sheet that will search through a GDrive folder and generate download
links which the IMI can use to grab the objects. Commented out is also a
line that will change permissions one at a time, only necessary for Team
Drive (Insert obvious scary language about allowing that level of access to
a script). Changing permissions, even via the API, can take a long time
especially on a directory with a large number of files in it. It's better
to change permissions on the folder level when possible (eg not in Team
Drive).
function listFilesInFolder(folderName) {
var ui = SpreadsheetApp.getUi();
var response = ui.prompt('Required', 'Enter Folder ID', ui.ButtonSet.OK_CANCEL);
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Name", "File-Id"]);
var folder = DriveApp.getFolderById(response.getResponseText());
var contents = folder.getFiles();
var cnt = 0;
var file;
while (contents.hasNext()) {
var file = contents.next();
cnt++;
// file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
// Replace {GOOGLEAPIKEY} in the following line with your api key.
// Instructions for getting API key: https://support.google.com/googleapi/answer/6158862?hl=en
var fileURL = "https://www.googleapis.com/drive/v3/files/" + file.getId() + "/?key={GOOGLEAPIKEY}&alt=media";
data = [
file.getName(),
fileURL,
];
sheet.appendRow(data);
};
};
'''
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#92>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AGn853zhCcDY-jGcLPGoj862Qrwb_9SOks5ulnS2gaJpZM4Xio5h>
.
--
Diego Pino Navarro
Digital Repositories Developer
Metropolitan New York Library Council (METRO)
|
@marksandford where do you feel this script/option should live in? Docs? Its own chapter? maybe a cookbook folder? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IMI can pull objects directly from a Google Drive with the following caveats/notes:
If it's useful, below is a Google Code snippet intended to be run in a Google Sheet that will search through a GDrive folder and generate download links which the IMI can use to grab the objects. Commented out is also a line that will change permissions one at a time, only necessary for Team Drive (Insert obvious scary language about allowing that level of access to a script). Changing permissions, even via the API, can take a long time especially on a directory with a large number of files in it. It's better to change permissions on the folder level when possible (eg not in Team Drive).
The text was updated successfully, but these errors were encountered: