-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Improve Google Picker #5532
Comments
An aside, and maybe this is a separate fix potentially but I noticed in the other PR #5443 the permission requested for Google Drive is: This should likely be EDIT: After testing with only Another update, it looks like since we're not actually getting the files and displaying them in a list with Uppy, there may not be much we can do here. After some research it might just be that you use |
Wow I can't believe this has been broken since 2021. Makes it seem like nobody really uses the google picker api. anyways thanks for doing the research. I've created a PR to fix it here: #5535 |
I tried to see if I can show the Google Photos thumbnails in the Uppy UI but it seems to be not easily doable because the baseUrl that we get from google's GET mediaItems API needs the Bearer access token header, which an |
I know. I responded too here on the issue and they said it's on the roadmap still but no ETA or timeline. Thanks for fixing that up! While we're at it for improvements and nice to haves. I noticed that Google Docs and all that aren't converted anymore to |
you mean the file extension in the uppy ui after selecting files? |
So with the old implementation of Uppy Google Drive when you scrolled through the files (before selecting) the file extensions showed up as |
@mifi is it possible to extend the Uppy Google Picker client to optionally use Companion for the auth flow? We work in a multi-tenant solution where every tenant has its own subdomain. This breaks the current Uppy Google Picker solution as the redirect from the Google auth popup comes back to that origin uri, not Companion. The only possible way we could fix this currently would be to add every tenant to the Alternatives here could be, we look after getting the auth token ourselves (not a problem) and then pass the token to Uppy somehow, but given this is what Companion is for, it feels like the better option. @StrixOSG This can be done fairly easily during the picker callback. With our current, native Google Picker, we have: const view = new window.google.picker.DocsView();
view.setMode(window.google.picker.DocsViewMode.LIST);
const sharedDrivesView = new window.google.picker.DocsView()
.setEnableDrives(true)
.setMode(window.google.picker.DocsViewMode.LIST)
.setIncludeFolders(true); // creates just the shared drives view
const sharedWithMeView = new window.google.picker.DocsView()
.setMode(window.google.picker.DocsViewMode.LIST)
.setOwnedByMe(false); // creates just the shared with me view
const picker = new window.google.picker.PickerBuilder()
.setAppId("<project id>")
.addView(view)
.addView(sharedDrivesView)
.addView(sharedWithMeView)
.enableFeature(window.google.picker.Feature.MULTISELECT_ENABLED)
.setMaxItems(10)
.setOAuthToken(googleDriveAuthToken)
.setCallback(pickerCallback) // Handle the response when files are selected
.build();
picker.setVisible(true);
. . .
// Handle the Google Picker response
const pickerCallback = (data) => {
if (data.action !== window.google.picker.Action.PICKED) {
return;
}
Promise.all(data.docs.map(exportGDocsInStandardFormat))
};
const exportGDocsInStandardFormat = (doc) => {
var url = "https://www.googleapis.com/drive/v3/files/" + doc.id;
var mimeType = doc.mimeType;
// Export Google Docs and Sheets as different formats, e.g., PDF or XLSX
if (doc.mimeType.includes("google-apps.document")) {
url += "/export?mimeType=application/pdf";
mimeType = "application/pdf";
doc.name += ".pdf";
} else if (doc.mimeType.includes("google-apps.spreadsheet")) {
url += "/export?mimeType=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
doc.name += ".xlsx";
} else {
url += "?alt=media";
}
var filename = doc.name;
return {
url,
filename,
mimeType,
};
}; |
+1 for sure on the picker implementation @mifi, thank you! I gave it a try and am able to pick files from my Google Drive, however my picked files fail to upload. If I continue to "Upload" the picked file that got staged in Uppy, then I see a 500 response from a POST request to my companion server's: /google-picker/get Companion logs:
Has anyone else experienced being able to PICK files but having uploads fail after selection? |
Does this happen with all kinds of files, or some specific kind only? I don't know how to reproduce. Googling for
We have limited capacity to work on this right now, so we need to prioritise. I will add all your suggestions/bugs to the OP of this issue. |
I just spent a few hours trying to figure out why Google Drive is not working in production but works fine in testing mode. it's allowing me to pick files but when trying to download the files in the companion it got 404. Turns out that my |
thanks @mifi using the project number resolved the issue for me! 🙏 |
Collection of bugs and potential improvements remaining for Google Picker (Photos/Drive) after initial implementation in #5443:
Bugs
drivepreopen
mystery Improve Google Picker #5532 (comment) Improve Google Picker #5532 (comment)Improvements
setSelectFolderEnabled(true)
The text was updated successfully, but these errors were encountered: