Allow uploading spreadsheet images to S3 #1951
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.