add settings for American Cloud storage
This commit is contained in:
@@ -1,19 +1,26 @@
|
|||||||
|
|
||||||
#AWS_ACCESS_KEY=???
|
#AWS_ACCESS_KEY=???
|
||||||
#AWS_BUCKET_NAME=image
|
#AWS_BUCKET_NAME=giftsimagetest
|
||||||
|
#AWS_ENDPOINT_SERVER=a2-west.americancloud.com
|
||||||
#AWS_REGION=US
|
#AWS_REGION=US
|
||||||
#AWS_SECRET_KEY=???
|
#AWS_SECRET_KEY=???
|
||||||
|
#S3_SET_ACL=true
|
||||||
AWS_ACCESS_KEY=???
|
AWS_ACCESS_KEY=???
|
||||||
AWS_BUCKET_NAME=gifts-image-test
|
AWS_BUCKET_NAME=gifts-image-test
|
||||||
|
AWS_ENDPOINT_SERVER=gifts-image-test.s3.amazonaws.com
|
||||||
AWS_REGION=us-west-1
|
AWS_REGION=us-west-1
|
||||||
AWS_SECRET_KEY=???
|
AWS_SECRET_KEY=???
|
||||||
|
#S3_SET_ACL=false
|
||||||
|
|
||||||
|
# needed to check limits
|
||||||
#ENDORSER_API_URL=http://localhost:3000
|
#ENDORSER_API_URL=http://localhost:3000
|
||||||
#ENDORSER_API_URL=https://test-api.endorser.ch
|
#ENDORSER_API_URL=https://test-api.endorser.ch
|
||||||
#ENDORSER_API_URL=https://api.endorser.ch
|
#ENDORSER_API_URL=https://api.endorser.ch
|
||||||
|
|
||||||
INFURA_PROJECT_ID=???
|
INFURA_PROJECT_ID=???
|
||||||
|
|
||||||
|
# host where the final image can be accessed by the public
|
||||||
|
# default is https://test-image.timesafari.app
|
||||||
#DOWNLOAD_IMAGE_SERVER=test-image.timesafari.app
|
#DOWNLOAD_IMAGE_SERVER=test-image.timesafari.app
|
||||||
|
|
||||||
# default is 3000
|
# default is 3000
|
||||||
|
|||||||
13
README.md
13
README.md
@@ -1,11 +1,7 @@
|
|||||||
# Image Server
|
# Image Server
|
||||||
|
|
||||||
Remaining:
|
Remaining:
|
||||||
- try American Cloud
|
|
||||||
- dockerize
|
- dockerize
|
||||||
- images.timesafari.app
|
|
||||||
|
|
||||||
- pretty-up the client, show thumbnail
|
|
||||||
|
|
||||||
## setup
|
## setup
|
||||||
|
|
||||||
@@ -47,4 +43,11 @@ JWT=`node -e "$CODE"`; curl -X DELETE -H "Authorization: Bearer $JWT" http://loc
|
|||||||
|
|
||||||
* Do the necessary steps from "setup" above.
|
* Do the necessary steps from "setup" above.
|
||||||
|
|
||||||
* In AWS, set up bucket and erase any test data.
|
* In object storage, set up bucket and erase any test data.
|
||||||
|
|
||||||
|
* In DNS, set a permanent web forward to the correct storage location.
|
||||||
|
|
||||||
|
|
||||||
|
## deploy to prod subsequent times
|
||||||
|
|
||||||
|
* Add CHANGELOG.md entry.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "image-trade",
|
"name": "Images for Trade",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ const endorserApiUrl = process.env.ENDORSER_API_URL || 'https://test-api.endorse
|
|||||||
|
|
||||||
// Configure AWS
|
// Configure AWS
|
||||||
const s3Client = new S3Client({
|
const s3Client = new S3Client({
|
||||||
|
endpoint: 'https://' + process.env.AWS_ENDPOINT_SERVER,
|
||||||
region: process.env.AWS_REGION,
|
region: process.env.AWS_REGION,
|
||||||
|
forcePathStyle: true,
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: process.env.AWS_ACCESS_KEY,
|
accessKeyId: process.env.AWS_ACCESS_KEY,
|
||||||
secretAccessKey: process.env.AWS_SECRET_KEY
|
secretAccessKey: process.env.AWS_SECRET_KEY
|
||||||
@@ -209,6 +211,9 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => {
|
|||||||
ContentType: reqFile.mimetype, // File content type
|
ContentType: reqFile.mimetype, // File content type
|
||||||
Key: fileName, // File name to use in S3
|
Key: fileName, // File name to use in S3
|
||||||
};
|
};
|
||||||
|
if (process.env.S3_SET_ACL === 'true') {
|
||||||
|
params.ACL = 'public-read';
|
||||||
|
}
|
||||||
const command = new PutObjectCommand(params);
|
const command = new PutObjectCommand(params);
|
||||||
const response = await s3Client.send(command);
|
const response = await s3Client.send(command);
|
||||||
if (response.$metadata.httpStatusCode !== 200) {
|
if (response.$metadata.httpStatusCode !== 200) {
|
||||||
@@ -224,6 +229,8 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => {
|
|||||||
console.error("Error deleting temp file", reqFile.path, "with error (but continuing):", err);
|
console.error("Error deleting temp file", reqFile.path, "with error (but continuing):", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// AWS URL: https://gifts-image-test.s3.amazonaws.com/gifts-image-test/FILE
|
||||||
|
// American Cloud URL: https://a2-west.americancloud.com/TENANT:giftsimagetest/FILE
|
||||||
return res.status(200).send(JSON.stringify({success: true, url: finalUrl}));
|
return res.status(200).send(JSON.stringify({success: true, url: finalUrl}));
|
||||||
}
|
}
|
||||||
} catch (uploadError) {
|
} catch (uploadError) {
|
||||||
|
|||||||
Reference in New Issue
Block a user