transloadit / uppy.io

The Uppy website
https://uppy.io
11 stars 27 forks source link

Use with your own server section of AWS S3 contains misleading routes #213

Closed nerg4l closed 6 months ago

nerg4l commented 6 months ago

The routes provided in the "Use with your own server" of AWS S3 uploader shows different endpoints than the endpoints used in the linked "Setup Uppy" example.

https://github.com/transloadit/uppy.io/blob/6a5a3bc89cabd80e01b289e136783002ea9b38ab/docs/uploader/aws-s3-multipart.mdx?plain=1#L143-L151

From the Setup Uppy example:

Murderlon commented 6 months ago

They are the same, it just shows that if you have an existing backend, perhaps even with existing s3 endpoints , you can just group them under /uppy route of whatever you'd like to do. When using the options for the s3 plugin you have to write the code manually anyway to call the backend.

nerg4l commented 6 months ago

Are you sure that only the prefix is different?

The documentation uses s3-multipart but the linked code example uses s3/multipart. Also the sign route is completely different.

Murderlon commented 6 months ago

Maybe the docs are misleading, but it just needs to match. You can do this if you want:

On the server:

app.post('/my/supercool/endpoint', (req, res, next) => {}

And then on the client:

const response = await fetch('/my/supercool/endpoint', {
  method: 'POST',
  // Send and receive JSON.
  headers: {
    accept: 'application/json',
  },
  body: serialize({
    filename: file.name,
    type: file.type,
    metadata,
  }),
  signal,
})

It's a lot of manual work. Ideally, we'd have @uppy/server-functions which you can use on the server, and force people to have the same endpoints as companion. Then I think you wouldn't need to manually write this.

nerg4l commented 6 months ago

Agreed, a companion compatible uploader config would be even better.

I was considering this option but could not find any documentation of the current endpoints used by Companion. I can dig through the code of course but I would prefer to have it in a more readable way.

Murderlon commented 6 months ago

I created two issues for it:

In the meantime if you're willing to contribute a PR to make the writing more clear in the current docs that would be great :)