-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
S3 file upload component #4030
Merged
Merged
S3 file upload component #4030
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…lugin-polyfill-node
… app theme, and use a unique nav background color for light theme
Codecov Report
@@ Coverage Diff @@
## develop #4030 +/- ##
========================================
Coverage 68.91% 68.91%
========================================
Files 139 139
Lines 4633 4633
Branches 685 685
========================================
Hits 3193 3193
Misses 1018 1018
Partials 422 422
Continue to review full report at Codecov.
|
…cting the datsource to use with the S3 upload component
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
This PR adds a component for uploading files to a S3 datsource. This new component is a familiar dropzone component which needs to be placed inside a form. Unlike normal dropzones, a button action is used to actually process the file upload.
In order to upload files to S3, you must have a S3 datasource configured with a valid access key and secret key that allows writing to whatever bucket you plan to upload files to.
S3 upload component
The new S3 upload component is a form component, and lives in the form category. The reason it is a form component rather than a standalone component is because it brings a few benefits which would otherwise not be possible:
The new component looks identical to the existing dropzone:
![image](https://user-images.githubusercontent.com/9075550/149483775-65f1fb99-bfb3-48ab-ae9a-1f31d096fa20.png)
It takes the same settings as the normal dropzone, but has a few extra ones for configuring where to upload the file. The additional settings are:
Uploading files
When you choose a file in the new component, it is displayed exactly the same as the normal dropzone component. Unlike the normal dropzone component, we do not read the full file into memory here or automatically upload it anywhere. We do still read image files into memory in order to generate a data URL to use as a preview.
Images files will show a preview:
![image](https://user-images.githubusercontent.com/9075550/149485097-22c4ab4f-b07f-4cbc-910f-7a4a140ecb43.png)
And non image files will not show a preview:
![image](https://user-images.githubusercontent.com/9075550/149485389-ccd633fe-65c1-43a3-a3b7-864796230915.png)
To send the upload, a new button action named "Upload File to S3" has been added. This takes one setting - what component you would like to upload:
![image](https://user-images.githubusercontent.com/9075550/149485928-2c721f13-a3d3-4b2c-85b9-cd174ebc4ee0.png)
One nice thing about file upload components - they are global (on the screen). You do not need to nest the button anywhere in particular in order to be able to reference a certain file upload component. Any button can upload any file.
As large files may be uploaded, the component displays a loading indicator and disables the component until the file is uploaded:
![image](https://user-images.githubusercontent.com/9075550/149487165-e4ccc7cd-8021-4ec9-b5c3-3a39751dc8f9.png)
Success or failure notifications will also be provided so you know whether or not the upload was successful:
![image](https://user-images.githubusercontent.com/9075550/149487257-7ecbffa1-44bc-42b2-9d2d-e050c901893a.png)
![image](https://user-images.githubusercontent.com/9075550/149487316-49b1d68c-69d8-4578-b64e-cf555e3c82d5.png)
Upload result
The URL of the file in S3 is included in the button outputs, so can be used in further button actions:
![image](https://user-images.githubusercontent.com/9075550/149502758-82e5f16e-4a42-4e42-9e5c-bdf245e20535.png)
![image](https://user-images.githubusercontent.com/9075550/149502705-069b2d9e-f560-4f54-8c65-3d4107f1009a.png)
Whether or not this file is publicly accessible is determined by the permissions on the bucket itself, and is up to the owner of the S3 bucket to determine.
Custom endpoints
S3 datasources with custom endpoints are not supported. This is mainly due to the non-compliance with presigned URL domain names. Real S3 uses
bucket.domain
as the FQDN, and using a custom endpoint when generating a presigned URL spits out a value of something likebucket.10.0.0.1
for example, if using a local IP address. Due to this behaviour we just have to put a limitiation on this functionality that it will only work with real S3 and not MinIO.Datasources with custom endpoints are filtered out of the list when selecting a datasource to use with the S3 upload component, which should help prevent confusion. There is also helper text displayed in the builder for this component which also states this. Finally the server will also explicitly state this if it does receive a request using a custom endpoint.