Skip to content

Commit

Permalink
Improve naming (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
gemcoder21 authored Sep 7, 2022
1 parent 48203e5 commit 62da8ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
19 changes: 7 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27115,6 +27115,7 @@ var __webpack_exports__ = {};
const S3 = __nccwpck_require__(3256);
const core = __nccwpck_require__(2186);
const fs = __nccwpck_require__(7147);
const path = __nccwpck_require__(1017);

try {
const endpoint = core.getInput('endpoint');
Expand All @@ -27131,18 +27132,12 @@ try {
signatureVersion: 'v4',
});

var uploadParams = { Bucket: bucket, Key: '', Body: '' };

var fileStream = fs.createReadStream(file);
fileStream.on('error', function (err) {
console.log('File Error', err);
core.setFailed(err);
});
uploadParams.Body = fileStream;
if (destination == "") {
var path = __nccwpck_require__(1017);
uploadParams.Key = path.basename(file);
} else { uploadParams.Key = destination; }
const fileContent = fs.readFileSync(file);
let uploadParams = {
Bucket: bucket,
Key: destination ? destination : path.basename(file),
Body: fileContent
};

// call S3 to retrieve upload file to specified bucket
s3.upload(uploadParams, function (err, data) {
Expand Down
19 changes: 7 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const S3 = require('aws-sdk/clients/s3');
const core = require('@actions/core');
const fs = require('fs');
const path = require('path');

try {
const endpoint = core.getInput('endpoint');
Expand All @@ -17,18 +18,12 @@ try {
signatureVersion: 'v4',
});

var uploadParams = { Bucket: bucket, Key: '', Body: '' };

var fileStream = fs.createReadStream(file);
fileStream.on('error', function (err) {
console.log('File Error', err);
core.setFailed(err);
});
uploadParams.Body = fileStream;
if (destination == "") {
var path = require('path');
uploadParams.Key = path.basename(file);
} else { uploadParams.Key = destination; }
const fileContent = fs.readFileSync(file);
let uploadParams = {
Bucket: bucket,
Key: destination ? destination : path.basename(file),
Body: fileContent
};

// call S3 to retrieve upload file to specified bucket
s3.upload(uploadParams, function (err, data) {
Expand Down

0 comments on commit 62da8ed

Please sign in to comment.