Skip to content

Commit

Permalink
Update AWS_S3Client and script
Browse files Browse the repository at this point in the history
  • Loading branch information
NguyenAnhTuan1912 committed Aug 20, 2024
1 parent d51ec84 commit e8868bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion backend/nodejs/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export NVM_DIR="$HOME/.nvm"
cd /home/backend/nodejs

export PYTHON_PATH="/home/backend/python/venv/bin/python"
export BUCKET_NAME="your_bucket_name";
export TEMP_PATH="/home/backend/temp"
export UPLOADS_PATH="/home/backend/uploads"
export BUCKET_NAME="your_bucket_name"

# Start NodeJS Server
npm start
Expand Down
20 changes: 13 additions & 7 deletions backend/nodejs/src/handlers/datatableImageToExcel.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,20 @@ export const DatatableImageToExcelHandler = createHandler(
if (err) throw err;

// Upload ảnh lên S3
s3Client.upload(bucketName, fileName, image.path).then(() => {
console.log("Image in", image.path, "is uploaded to S3");
// Tải lên rồi thì xóa ảnh và file.
fs.unlink(image.path, function (err) {
if (err) throw err;
console.log("Image in", image.path, " was deleted.");
s3Client
.upload(
bucketName,
image.filename,
path.resolve(image.path, image.filename)
)
.then(() => {
console.log("Image in", image.path, "is uploaded to S3");
// Tải lên rồi thì xóa ảnh và file.
fs.unlink(image.path, function (err) {
if (err) throw err;
console.log("Image in", image.path, " was deleted.");
});
});
});

fs.unlink(excelFileFullPath, function (err) {
if (err) throw err;
Expand Down
2 changes: 1 addition & 1 deletion gui/js/apis/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const API_ROOT = "http://ec2-47-128-221-225.ap-southeast-1.compute.amazonaws.com/api";
export const API_ROOT = "http://ec2-47-129-229-78.ap-southeast-1.compute.amazonaws.com/api";

0 comments on commit e8868bf

Please sign in to comment.