uppy/examples/aws-php/main.js
Prakash 1bb94b8759 fix(examples): align aws-s3 examples with rewritten plugin API
- aws-nodejs: STS mode now passes s3Endpoint (required when using
  getCredentials in the new plugin; previously threw "s3Endpoint must
  be a string" at install time).
- companion-digitalocean-spaces: rename companionUrl → companionEndpoint
  (option renamed in the rewrite). Update README links from
  /docs/aws-s3-multipart to /docs/aws-s3.
- aws-php: migrate from removed getUploadParameters to signRequest.
  Backend (s3-sign.php) returns just { url } now; client no longer
  receives method/fields/headers.
2026-05-25 19:23:19 +05:30

34 lines
895 B
JavaScript

import AwsS3 from '@uppy/aws-s3'
import Uppy from '@uppy/core'
import Dashboard from '@uppy/dashboard'
const uppy = new Uppy({
debug: true,
})
uppy.use(Dashboard, {
inline: true,
target: 'body',
})
uppy.use(AwsS3, {
// The PHP backend only signs single PutObject URLs (no multipart).
shouldUseMultipart: false,
// signRequest is called for each S3 operation. For single PUTs the
// request is `{ method: 'PUT', key }`. The server returns a presigned URL.
signRequest: async (request) => {
const response = await fetch('/s3-sign.php', {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
},
body: JSON.stringify({
method: request.method,
key: request.key,
}),
})
if (!response.ok) throw new Error('Failed to get presigned URL')
return response.json()
},
})