Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
186174f8
Commit
186174f8
authored
Oct 19, 2019
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: asset upload/move/delete for S3 module
parent
d9870583
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
common.js
server/modules/storage/s3/common.js
+28
-0
No files found.
server/modules/storage/s3/common.js
View file @
186174f8
...
...
@@ -70,4 +70,32 @@ module.exports = class S3CompatibleStorage {
await
this
.
s3
.
copyObject
({
CopySource
:
sourceFilePath
,
Key
:
destinationFilePath
}).
promise
()
await
this
.
s3
.
deleteObject
({
Key
:
sourceFilePath
}).
promise
()
}
/**
* ASSET UPLOAD
*
* @param {Object} asset Asset to upload
*/
async
assetUploaded
(
asset
)
{
WIKI
.
logger
.
info
(
`(STORAGE/
${
this
.
storageName
}
) Creating new file
${
asset
.
path
}
...`
)
await
this
.
s3
.
putObject
({
Key
:
asset
.
path
,
Body
:
asset
.
data
}).
promise
()
}
/**
* ASSET DELETE
*
* @param {Object} asset Asset to delete
*/
async
assetDeleted
(
asset
)
{
WIKI
.
logger
.
info
(
`(STORAGE/
${
this
.
storageName
}
) Deleting file
${
asset
.
path
}
...`
)
await
this
.
s3
.
deleteObject
({
Key
:
asset
.
path
}).
promise
()
}
/**
* ASSET RENAME
*
* @param {Object} asset Asset to rename
*/
async
assetRenamed
(
asset
)
{
WIKI
.
logger
.
info
(
`(STORAGE/
${
this
.
storageName
}
) Renaming file from
${
asset
.
path
}
to
${
asset
.
destinationPath
}
...`
)
await
this
.
s3
.
copyObject
({
CopySource
:
asset
.
path
,
Key
:
asset
.
destinationPath
}).
promise
()
await
this
.
s3
.
deleteObject
({
Key
:
asset
.
path
}).
promise
()
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment