Skip to content
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

Allow uploading spreadsheet images to S3 #1951

Merged
merged 3 commits into from
Jan 9, 2024
Merged

Allow uploading spreadsheet images to S3 #1951

merged 3 commits into from
Jan 9, 2024

Conversation

ebroder
Copy link
Member

@ebroder ebroder commented Jan 8, 2024

Given that the Apps Script API for uploading images into a spreadsheet has a laughably small size limit of 1 million pixels (#1354), provide an alternative of staging images in S3 before inserting them into the spreadsheet.

This adds a new S3 bucket configuration option. When configured, we verify that (a) we're able to upload to the bucket and (b) the resulting objects are publicly accessible.

It also changes the insert image flow. After receiving an uploaded image, the client first requests from the server a pre-signed S3 upload request. If the S3 bucket is configured, the server generates and returns one. The client then uses the request details to upload the image to S3 before sending the resulting public image URL to Google Sheets (using the existing functionality to insert an image by URL).

If the S3 bucket isn't configured, the server returns an empty but non-error response, and the client proceeds to upload the image directly to Google Sheets as we've done in the past (but still subject to the 1M pixel limit).

Fixes #1354.

Expose a new method which generates a pre-signed S3 upload to the S3
image bucket if an image bucket is configured. Then on the client side,
when uploading an image to a spreadsheet, attempt to get a pre-signed S3
URL. If that works, upload the image and insert the image by URL into
the spreadsheet. If it doesn't work, fall back to the old method of
uploading the image to Google Sheets and inserting it as a blob.
@ebroder ebroder requested a review from zarvox January 8, 2024 19:14
@ebroder ebroder merged commit 28ca259 into main Jan 9, 2024
1 check passed
@ebroder ebroder deleted the evan/s3-images branch January 9, 2024 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Google's image upload limit is prohibitively small
2 participants