mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 22:54:42 -04:00
Upload file to s3: make public a file on upload and allow to configure destination folder
New configurations: - s3folder: (string) folder to save the files inside bucket - s3publicFiles: (boolean) indicate if should send ACL parameters Signed-off-by: Lautaro Alvarez <lautarolalvarez@gmail.com>
This commit is contained in:
parent
8643d9cc99
commit
3585dc9ee6
4 changed files with 18 additions and 11 deletions
|
@ -28,12 +28,13 @@ exports.uploadImage = function (imagePath, callback) {
|
|||
}
|
||||
const params = {
|
||||
Bucket: config.s3bucket,
|
||||
Key: path.join('uploads', path.basename(imagePath)),
|
||||
Key: path.join(config.s3folder, path.basename(imagePath)),
|
||||
Body: buffer
|
||||
}
|
||||
|
||||
const mimeType = getImageMimeType(imagePath)
|
||||
if (mimeType) { params.ContentType = mimeType }
|
||||
if (config.s3publicFiles) { params.ACL = 'public-read' }
|
||||
|
||||
logger.debug(`S3 object parameters: ${JSON.stringify(params)}`)
|
||||
s3.putObject(params, function (err, data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue