packages/@uppy/companion/src/server/controllers/s3.js
function createMultipartUpload (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.body.filename)
    const { type } = req.body
    if (typeof key !== 'string') {
      return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' })
    }
    if (typeof type !== 'string') {
      return res.status(400).json({ error: 's3: content type must be a string' })
    }

    client.createMultipartUpload({
      Bucket: config.bucket,
      Key: key,
      ACL: config.acl,
      ContentType: type,
      Expires: ms('5 minutes') / 1000
    }, (err, data) => {
      if (err) {
        next(err)
        return
      }
      res.json({
        key: data.Key,
        uploadId: data.UploadId
      })
    })
  }
function createMultipartUpload (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.body.filename)
    const { type } = req.body
    if (typeof key !== 'string') {
      return res.status(500).json({ error: 's3: filename returned from `getKey` must be a string' })
    }
    if (typeof type !== 'string') {
      return res.status(400).json({ error: 's3: content type must be a string' })
    }

    client.createMultipartUpload({
      Bucket: config.bucket,
      Key: key,
      ACL: config.acl,
      ContentType: type,
      Expires: ms('5 minutes') / 1000
    }, (err, data) => {
      if (err) {
        next(err)
        return
      }
      res.json({
        key: data.Key,
        uploadId: data.UploadId
      })
    })
  }
function createMultipartUpload ( 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 . body . filename ) const { type } = req . body if ( typeof key !== 'string' ) { return res . status ( 500 ) . json ( { error : 's3: filename returned from `getKey` must be a string' } ) } if ( typeof type !== 'string' ) { return res . status ( 400 ) . json ( { error : 's3: content type must be a string' } ) } client . createMultipartUpload ( { Bucket : config . bucket , Key : key , ACL : config . acl , ContentType : type , Expires : ms ( '5 minutes' ) / 1000 } , ( err , data ) => { if ( err ) { next ( err ) return } res . json ( { key : data . Key , uploadId : data . UploadId } ) } ) }
Create an S3 multipart upload. With this, files can be uploaded in chunks of 5MB+ each.

Expected JSON body:
- 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:
- key - The object key in the S3 bucket.
- uploadId - The ID of this multipart upload, to be used in later requests.
Create an S3 multipart upload . With this files can be uploaded in chunks of 5MB + each .