Conversation
d418f94 to
e093eb5
Compare
| type: "object", | ||
| properties: { | ||
| type: { const: "storage" }, | ||
| archive: { type: "number", minimum: 30 }, |
There was a problem hiding this comment.
this was unused in the construct
|
|
||
| exports.handler = async (event) => { | ||
| const body = JSON.parse(event.body); | ||
| const fileName = \`tmp/\${crypto.randomBytes(5).toString('hex')}-\${body.fileName}\`; |
There was a problem hiding this comment.
this generates a random file name to avoid collisions by adding a random hash before the submitted filename.
| cors: [ | ||
| { | ||
| allowedMethods: [HttpMethods.PUT], | ||
| allowedOrigins: ["*"], |
There was a problem hiding this comment.
for this first version I chose to set wide CORS permissions. We may add an option to configure it later.
|
|
||
| outputs(): Record<string, () => Promise<string | undefined>> { | ||
| return { | ||
| bucketName: () => this.getBucketName(), |
There was a problem hiding this comment.
it would be nice to output the full upload URL but I wasn't able to generate it properly for Rest APIs. Another problem was that people may have domains configured on their API Gateway or they may be using the server-side construct which woul make the outputed URL useless.
|
See some working examples here https://github.com/t-richard/lift-upload-example Steps to deploy it are in the README |
0923fa8 to
b0d4e35
Compare
|
This is really cool! |
b0d4e35 to
41e89d5
Compare
See the docs for explanations.