mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 19:35:13 +08:00
d295a16dab
This pull request introduces the endpoints required, and the JavaScript functionality in the `ComposerUppyUpload` mixin, for direct S3 multipart uploads. There are four new endpoints in the uploads controller:
* `create-multipart.json` - Creates the multipart upload in S3 along with an `ExternalUploadStub` record, storing information about the file in the same way as `generate-presigned-put.json` does for regular direct S3 uploads
* `batch-presign-multipart-parts.json` - Takes a list of part numbers and the unique identifier for an `ExternalUploadStub` record, and generates the presigned URLs for those parts if the multipart upload still exists and if the user has permission to access that upload
* `complete-multipart.json` - Completes the multipart upload in S3. Needs the full list of part numbers and their associated ETags which are returned when the part is uploaded to the presigned URL above. Only works if the user has permission to access the associated `ExternalUploadStub` record and the multipart upload still exists.
After we confirm the upload is complete in S3, we go through the regular `UploadCreator` flow, the same as `complete-external-upload.json`, and promote the temporary upload S3 into a full `Upload` record, moving it to its final destination.
* `abort-multipart.json` - Aborts the multipart upload on S3 and destroys the `ExternalUploadStub` record if the user has permission to access that upload.
Also added are a few new columns to `ExternalUploadStub`:
* multipart - Whether or not this is a multipart upload
* external_upload_identifier - The "upload ID" for an S3 multipart upload
* filesize - The size of the file when the `create-multipart.json` or `generate-presigned-put.json` is called. This is used for validation.
When the user completes a direct S3 upload, either regular or multipart, we take the `filesize` that was captured when the `ExternalUploadStub` was first created and compare it with the final `Content-Length` size of the file where it is stored in S3. Then, if the two do not match, we throw an error, delete the file on S3, and ban the user from uploading files for N (default 5) minutes. This would only happen if the user uploads a different file than what they first specified, or in the case of multipart uploads uploaded larger chunks than needed. This is done to prevent abuse of S3 storage by bad actors.
Also included in this PR is an update to vendor/uppy.js. This has been built locally from the latest uppy source at
|
||
---|---|---|
.. | ||
client.ar.yml | ||
client.be.yml | ||
client.bg.yml | ||
client.bs_BA.yml | ||
client.ca.yml | ||
client.cs.yml | ||
client.da.yml | ||
client.de.yml | ||
client.el.yml | ||
client.en_GB.yml | ||
client.en.yml | ||
client.es.yml | ||
client.et.yml | ||
client.fa_IR.yml | ||
client.fi.yml | ||
client.fr.yml | ||
client.gl.yml | ||
client.he.yml | ||
client.hu.yml | ||
client.hy.yml | ||
client.id.yml | ||
client.it.yml | ||
client.ja.yml | ||
client.ko.yml | ||
client.lt.yml | ||
client.lv.yml | ||
client.nb_NO.yml | ||
client.nl.yml | ||
client.pl_PL.yml | ||
client.pt_BR.yml | ||
client.pt.yml | ||
client.ro.yml | ||
client.ru.yml | ||
client.sk.yml | ||
client.sl.yml | ||
client.sq.yml | ||
client.sr.yml | ||
client.sv.yml | ||
client.sw.yml | ||
client.te.yml | ||
client.th.yml | ||
client.tr_TR.yml | ||
client.uk.yml | ||
client.ur.yml | ||
client.vi.yml | ||
client.zh_CN.yml | ||
client.zh_TW.yml | ||
names.yml | ||
plurals.rb | ||
server.ar.yml | ||
server.be.yml | ||
server.bg.yml | ||
server.bs_BA.yml | ||
server.ca.yml | ||
server.cs.yml | ||
server.da.yml | ||
server.de.yml | ||
server.el.yml | ||
server.en_GB.yml | ||
server.en.yml | ||
server.es.yml | ||
server.et.yml | ||
server.fa_IR.yml | ||
server.fi.yml | ||
server.fr.yml | ||
server.gl.yml | ||
server.he.yml | ||
server.hu.yml | ||
server.hy.yml | ||
server.id.yml | ||
server.it.yml | ||
server.ja.yml | ||
server.ko.yml | ||
server.lt.yml | ||
server.lv.yml | ||
server.nb_NO.yml | ||
server.nl.yml | ||
server.pl_PL.yml | ||
server.pt_BR.yml | ||
server.pt.yml | ||
server.ro.yml | ||
server.ru.yml | ||
server.sk.yml | ||
server.sl.yml | ||
server.sq.yml | ||
server.sr.yml | ||
server.sv.yml | ||
server.sw.yml | ||
server.te.yml | ||
server.th.yml | ||
server.tr_TR.yml | ||
server.uk.yml | ||
server.ur.yml | ||
server.vi.yml | ||
server.zh_CN.yml | ||
server.zh_TW.yml | ||
transliterate.ar.yml | ||
transliterate.bg.yml | ||
transliterate.de.yml | ||
transliterate.el.yml | ||
transliterate.en.yml | ||
transliterate.ru.yml | ||
transliterate.vi.yml |