CreateMultipartUpload endpoint
https://redmine.teklia.com/issues/9153
To start supporting uploads of DataFiles and ModelVersions larger than 5GB, we need to implement proxies between an API client and the S3 API to support multipart uploads. The first step is declaring a new multipart upload, under which parts will be uploaded one by one.
A new CreateMultipartUpload endpoint should be introduced as a POST /api/v1/multipart/. As all of the multipart endpoints will have some shared parameters, two serializers need to be declared:
-
MultipartUploadSerializer, the shared serializer-
object_type: write-only and required EnumField accepting the valuesmodel_versionanddata_file -
object_id: write-only and required UUIDField -
upload_id: required CharField for the multipart upload ID returned by S3 - The
validate()method should return an updateddatadict with an extraobjectkey. This key contains a ModelVersion or a DataFile instance, retrieved from theobject_typeandobject_id. - The serializer validation raises HTTP 404 when:
- the object does not exist
- the user does not have read access to the DataFile's project or the ModelVersion's model
- the ModelVersion's model is archived
- The serializer validation raises HTTP 403 when the object exists and the user has read access, but not contributor access to the DataFile's project or the ModelVersion's model.
-
-
MultipartUploadCreateSerializer, used by this specific endpoint-
upload_idmust be marked as read-only since we will be generating it in this endpoint -
checksum_algorithmis an optional, nullable EnumField accepting the names of the multipart upload checksum algorithms - the
create()method must:- call
object.s3_object.initiate_multipart_upload(ChecksumAlgorithm=checksum_algorithm)(docs) - handle
botocore.exceptions.ClientErrorexceptions, raising aValidationErrorwith thee.response["Error"]["Message"]whene.response["Error"]["Code"] == "400" - return
{"upload_id": id}, from theidof the object returned byinitiate_multipart_upload.
- call
-