-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy paths3-direct.ts
More file actions
23 lines (19 loc) · 879 Bytes
/
s3-direct.ts
File metadata and controls
23 lines (19 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import express from 'express';
import { type LogLevel, uploadx } from '@uploadx/core';
import { S3Storage } from '@uploadx/s3';
const PORT = process.env.PORT || 3002;
const app = express();
// The credentials are loaded from a shared credentials file or environment variables
const storage = new S3Storage({
maxUploadSize: '5GB',
allowMIME: ['image/*', 'video/*'],
bucket: 'my-bucket',
requestChecksumCalculation: 'WHEN_REQUIRED', // remove useless crc32 checksum headers
forcePathStyle: true,
clientDirectUpload: true, // send presigned urls to the client for upload directly to S3 storage
partSize: '8MB', // optionally override part size
expiration: { maxAge: '1h', purgeInterval: '15min' },
logLevel: <LogLevel>process.env.LOG_LEVEL || 'info'
});
app.use('/files', uploadx({ storage }));
app.listen(PORT, () => console.log('Listening on port:', PORT));