packages/@uppy/companion/src/server/controllers/s3.js
function getUploadParameters (req, res, next) {
    // @ts-ignore The `uppy` property is added by middleware before reaching here.
    const client = req.uppy.s3Client
    const key = config.getKey(req, req.query.filename)
    if (typeof key !== 'string') {
      return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' })
    }

    const fields = {
      acl: config.acl,
      key: key,
      success_action_status: '201',
      'content-type': req.query.type
    }

    client.createPresignedPost({
      Bucket: config.bucket,
      Expires: ms('5 minutes') / 1000,
      Fields: fields,
      Conditions: config.conditions
    }, (err, data) => {
      if (err) {
        next(err)
        return
      }
      res.json({
        method: 'post',
        url: data.url,
        fields: data.fields
      })
    })
  }
function getUploadParameters (req, res, next) {
    // @ts-ignore The `uppy` property is added by middleware before reaching here.
    const client = req.uppy.s3Client
    const key = config.getKey(req, req.query.filename)
    if (typeof key !== 'string') {
      return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' })
    }

    const fields = {
      acl: config.acl,
      key: key,
      success_action_status: '201',
      'content-type': req.query.type
    }

    client.createPresignedPost({
      Bucket: config.bucket,
      Expires: ms('5 minutes') / 1000,
      Fields: fields,
      Conditions: config.conditions
    }, (err, data) => {
      if (err) {
        next(err)
        return
      }
      res.json({
        method: 'post',
        url: data.url,
        fields: data.fields
      })
    })
  }
function getUploadParameters ( req , res , next ) { // @ts-ignore The `uppy` property is added by middleware before reaching here. const client = req . uppy . s3Client const key = config . getKey ( req , req . query . filename ) if ( typeof key !== 'string' ) { return res . status ( 500 ) . json ( { error : 's3: filename returned from `getKey` must be a string' } ) } const fields = { acl : config . acl , key : key , success_action_status : '201' , 'content-type' : req . query . type } client . createPresignedPost ( { Bucket : config . bucket , Expires : ms ( '5 minutes' ) / 1000 , Fields : fields , Conditions : config . conditions } , ( err , data ) => { if ( err ) { next ( err ) return } res . json ( { method : 'post' , url : data . url , fields : data . fields } ) } ) }
Get upload paramaters for a simple direct upload.

Expected query parameters:
- filename - The name of the file, given to the `config.getKey`
option to determine the object key name in the S3 bucket.
- type - The MIME type of the file.

Response JSON:
- method - The HTTP method to use to upload.
- url - The URL to upload to.
- fields - Form fields to send along.
Get upload paramaters for a simple direct upload .