keygen-sh / keygen-api

Keygen is a fair source software licensing and distribution API built with Ruby on Rails. For developers, by developers.
https://keygen.sh
Other
824 stars 53 forks source link

Add support for multipart artifact uploads #706

Open ezekg opened 1 year ago

ezekg commented 1 year ago

This would remove the 5GB artifact size limit we currently have. This would need to be implemented as a flag during upload, e.g. meta.multipart, because the process is entirely different than when using a singular presigned upload URL. Artifact-related jobs would also need to be adjusted.

Originally posted by @dnewkerk in https://github.com/aws/aws-sdk-js/issues/468#issuecomment-167012681:

@andrewgoodchild apologies if I was unclear, though on my end presigned multipart uploads are working. The gist you mentioned was me sharing with trevor how I had previously coded the authorization header before getting presigned multipart uploads working.

This is my new version of the (ruby) code that works for getting presigned urls for both single and multipart uploads. Hopefully seeing this will give you ideas for how to solve it similarly in your code:

presigner = Aws::S3::Presigner.new
if upload.multipart?
  presigner.presigned_url(:upload_part, bucket: upload.bucket, key: upload.filename,
    upload_id: upload.multipart_id, part_number: upload_part.part_number)
else
  presigner.presigned_url(:put_object, bucket: upload.bucket, key: upload.filename)
end

Notice how the first parameter of the presigned_url method is different between single and multipart uploads, and that multipart uploads take the regular key (filename) just like single part uploads, but also add parameters for setting the upload_id and part_number.

Hope this helps :)

Ref https://github.com/keygen-sh/keygen-cli/issues/6.