thomasreichmann / upload-thomasar

Simple upload application for sharing files
https://upload-thomasar.vercel.app
0 stars 0 forks source link

create the useUpload hook #9

Closed thomasreichmann closed 2 months ago

thomasreichmann commented 2 months ago

useUpload Structure

1. Client Requirements

What users of this hook will need:

thomasreichmann commented 2 months ago

Endpoints for uppy functionality (will become operations)

these came from https://github.com/thomasreichmann/aws-file-manager

  1. POST /api/upload/presign

    • Description: Initiates a multipart upload and returns uploadId and key.
    • Request Body:
      {
      "filename": "string",
      "storageClass": "string (optional)"
      }
    • Response:
      {
      "uploadId": "string",
      "key": "string"
      }
  2. GET /api/upload/presign

    • Description: Generates a signed URL for uploading a specific part of the file.
    • Query Parameters:
      • filename: The file name.
      • uploadId: The upload ID from the multipart upload.
      • partNumber: The part number.
    • Response: The signed URL for the specified part.
  3. PUT /api/upload/presign

    • Description: Completes the multipart upload.
    • Request Body:
      {
      "uploadId": "string",
      "parts": [
       { "ETag": "string", "PartNumber": number }
      ],
      "filename": "string"
      }
    • Response:
      {
      "message": "statusCode"
      }
  4. DELETE /api/upload/presign

    • Description: Aborts an ongoing multipart upload.
    • Query Parameters:
      • uploadId: The upload ID to be aborted.
      • key: The file key (filename).
    • Response: Confirmation message that the upload was aborted.
  5. GET /api/upload/parts

    • Description: Lists parts for a given multipart upload.
    • Query Parameters:
      • uploadId: The upload ID.
      • key: The file key (filename).
    • Response: List of uploaded parts for the specified multipart upload.
      [
      {
       "PartNumber": number,
       "ETag": "string"
      }
      ]
thomasreichmann commented 2 months ago

Hook is now created, mostly working and still needs a lot of improvements, but the requirements that this issue outlined are mostly completed. The rest will become individual tickets now that uploading actually works at least