forked from GEOLYTIX/xyz
-
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
1 parent
75f48a2
commit 2a85231
Showing
2 changed files
with
23 additions
and
36 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
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 |
---|---|---|
@@ -1,44 +1,35 @@ | ||
/** | ||
@module /provider/s3 | ||
@deprecated | ||
### /provider/s3 | ||
@description | ||
Provides a way to call get, put, trash and list. Directly interfaces with s3 | ||
The S3 provider module requires the [S3 signer]{@link module:/sign/s3} and will return a signed request URL. | ||
@requires /sign/s3 | ||
This module has been deprecated and replaced with {@link module:/sign/s3~s3} | ||
@module /provider/s3 | ||
*/ | ||
|
||
const s3_signer = require('../sign/s3') | ||
|
||
if (!s3_signer) { | ||
|
||
module.exports = null | ||
} else { | ||
|
||
module.exports = s3_provider | ||
} | ||
|
||
/** | ||
@function s3 | ||
@async | ||
@function s3_provider | ||
@description | ||
The s3 provider method will redirect requests to the signer. | ||
Provides methods for list, get, trash and put | ||
The s3_provider method returns the s3_signer method. | ||
@param {Object} req HTTP request. | ||
@param {Object} res HTTP response. | ||
@param {Object} req.params Request parameter. | ||
@returns {Request} A redirect to the s3 signer. | ||
@returns {Function} The s3_signer module method. | ||
**/ | ||
module.exports = async function s3(req, res) { | ||
|
||
// const commands = { | ||
// get, | ||
// put, | ||
// trash, | ||
// list | ||
// } | ||
|
||
// if (!Object.hasOwn(commands, req.params.command)) { | ||
// return res.status(400).send(`S3 command validation failed.`) | ||
// } | ||
|
||
const paramString = Object.keys(req.params).filter(param => ['command','bucket','key','region'].includes(param)).map(param => `${param}=${req.params[param]}`).join('&') | ||
|
||
res.setHeader('location', `${process.env.DIR}/api/sign/s3?${paramString}`) | ||
|
||
return res.status(301).send() | ||
async function s3_provider(req, res) { | ||
|
||
return s3_signer(req, res) | ||
} |