-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
147 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ yarn-error.log* | |
/frontend/.env | ||
/dist/ | ||
/local/ | ||
/locals3root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#s3cmd --host http://localhost:9090 ls s3://maestro --no-ssl | ||
services: | ||
s3mock: | ||
image: adobe/s3mock:latest | ||
container_name: maestro_s3 | ||
environment: | ||
- debug=true | ||
- retainFilesOnExit=true | ||
- root=containers3root | ||
- initialBuckets=maestro | ||
ports: | ||
- 9090:9090 | ||
volumes: | ||
- ./locals3root:/containers3root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { DocumentToCreate } from '../../shared/schema/Document/Document'; | ||
import { PutObjectCommand, S3 } from '@aws-sdk/client-s3'; | ||
import config from '../utils/config'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
import { getSignedUrl as getS3SignedUrl } from '@aws-sdk/s3-request-presigner'; | ||
export const getUploadSignedUrlS3 = async (filename: DocumentToCreate['filename']): Promise<{url: string, documentId: string}> => { | ||
|
||
|
||
console.log('Get signed url for file', filename); | ||
|
||
const client = new S3({ | ||
...config.s3.client, | ||
//FIXME forcePathStyle for S3Mock | ||
forcePathStyle: true | ||
} | ||
); | ||
const id = uuidv4(); | ||
const key = `${id}_${filename}`; | ||
|
||
const command = new PutObjectCommand({ | ||
Bucket: config.s3.bucket, | ||
Key: key, | ||
}); | ||
|
||
const url = await getS3SignedUrl(client, command, { expiresIn: 3600 }); | ||
|
||
|
||
|
||
return {url, documentId: id} | ||
}; |