Skip to content

Commit

Permalink
feat(aws): add progress indicator for uploads (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Almouro authored Sep 14, 2022
1 parent 9a771a0 commit ba86182
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
1 change: 0 additions & 1 deletion packages/aws-device-farm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"dependencies": {
"@aws-sdk/client-device-farm": "^3.154.0",
"@perf-profiler/logger": "^0.2.0",
"axios": "^0.27.2",
"commander": "^9.4.0"
}
}
23 changes: 5 additions & 18 deletions packages/aws-device-farm/src/uploadFile.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
import fs from "fs";
import axios from "axios";
import { Logger } from "@perf-profiler/logger";
import { execSync } from "child_process";

export const uploadFile = async (url: string, filePath: string) => {
Logger.info(`Uploading ${filePath}...`);

const read_stream = fs.createReadStream(filePath);
const { size } = fs.statSync(filePath);

await axios({
method: "put",
url: url,
maxContentLength: Infinity,
maxBodyLength: Infinity,
headers: {
"Content-Length": size,
},
data: read_stream,
onUploadProgress: (progressEvent) => console.log(progressEvent),
});

execSync(
`curl -T ${filePath} "${url}" --fail --progress-bar -o /tmp/upload_${new Date().getTime()}.txt`,
{ stdio: "inherit" }
);
Logger.info(`Upload of ${filePath} done`);
};
19 changes: 1 addition & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5085,14 +5085,6 @@ axios@^0.21.1:
dependencies:
follow-redirects "^1.14.0"

axios@^0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
dependencies:
follow-redirects "^1.14.9"
form-data "^4.0.0"

axobject-query@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
Expand Down Expand Up @@ -7311,7 +7303,7 @@ flipper-plugin@latest:
string-natural-compare "^3.0.0"
uuid "^8.3.2"

follow-redirects@^1.14.0, follow-redirects@^1.14.9:
follow-redirects@^1.14.0:
version "1.15.1"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5"
integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==
Expand All @@ -7330,15 +7322,6 @@ form-data@^3.0.0:
combined-stream "^1.0.8"
mime-types "^2.1.12"

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

form-data@~2.3.2:
version "2.3.3"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6"
Expand Down

0 comments on commit ba86182

Please sign in to comment.