Direct Uploads

POST /direct_uploads

This endpoint manages direct-to-s3 uploads. You must POST metadata about the file you wish to upload directly. On success, a “blob” will be created in the database, which in this case is strictly only a reference to the location fo the file on S3. Despite the name, it does not contain the actual file data.

The request returns a signed AWS S3 url to which the actual file content should be posted. When that post has completed, then—and only then—you may submit a scan to the /scans endpoint to store a scan associated with the user.

Endpoint

POST /api/v2/direct_uploads

Parameters

Name Description type
blob[content_type] required Content Type string
blob[filename] required Filename string
blob[checksum] required MD5 Checksum string
blob[byte_size] required Size in bytes number

Request

Route

POST /api/v2/direct_uploads

Headers

Accept: application/json
Content-Type: application/json
Access-Token: hFZbGbb5VG4AiDKAdJmjDQ
Client: zSHoTHrQ_wFB0-EmH5us-g
Uid: test@example.com

Body

{
  "blob": {
    "content_type": "text/plain",
    "filename": "test.obj",
    "checksum": "ah59gycxlQLQuD7UA4GblA==",
    "byte_size": "1024"
  }
}

Response

Status

200

Headers

Content-Type: application/json; charset=utf-8
Access-Token: hFZbGbb5VG4AiDKAdJmjDQ
Token-Type: Bearer
Client: zSHoTHrQ_wFB0-EmH5us-g
Expiry: 1894737365
Uid: test@example.com

Body

{
  "id": 1251,
  "key": "Ho8YdJ94FveK3H6brJvWS2D4",
  "filename": "test.obj",
  "content_type": "text/plain",
  "metadata": {
  },
  "byte_size": 1024,
  "checksum": "ah59gycxlQLQuD7UA4GblA==",
  "created_at": "2020-01-15T19:56:05.416Z",
  "signed_id": "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBdU1FIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--8f3f26d5dd40b8a33335ba3a3ce58089b14b69d7",
  "direct_upload": {
    "url": "http://example.org:3002/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDVG9JYTJWNVNTSWRTRzg0V1dSS09UUkdkbVZMTTBnMlluSktkbGRUTWtRMEJqb0dSVlE2RVdOdmJuUmxiblJmZEhsd1pVa2lEM1JsZUhRdmNHeGhhVzRHT3daVU9oTmpiMjUwWlc1MFgyeGxibWQwYUdrQ0FBUTZEV05vWldOcmMzVnRTU0lkWVdnMU9XZDVZM2hzVVV4UmRVUTNWVUUwUjJKc1FUMDlCanNHVkE9PSIsImV4cCI6IjIwMjAtMDEtMTVUMjA6MDE6MDUuNDE3WiIsInB1ciI6ImJsb2JfdG9rZW4ifX0=--7be10afd0ae5fdbcf2e009cecd87b1181a7f4ef4",
    "headers": {
      "Content-Type": "text/plain"
    }
  }
}