Skip to content

Commit

Permalink
feat: add single file uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Mar 25, 2023
1 parent fb6bb1a commit 182e4b5
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions local/single-dicom-uploader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require("path");
process.chdir(path.join(__dirname,"../"));
require("rootpath")();
require("dotenv").config();
const { stow } = require("../api/dicom-web/stow/service/stow");
const os = require("os");
const { program } = require("commander");

let osPlatform = os.platform().toLocaleLowerCase();
if (osPlatform.includes("linux")) {
process.env.ENV = "linux";
} else if (osPlatform.includes("win")) {
process.env.ENV = "windows";
}

program.requiredOption("-f, --file <string>", "The DICOM file that need to upload");
program.parse();

const options = program.opts();

let filePath = options.file;
async function main() {
console.log(`input file: ${filePath}`);

let storeInstanceResult = await stow(
{
headers: {
host: "localhost:8081"
}
},
filePath
);

if (storeInstanceResult.isFailure) {
console.error(storeInstanceResult.message);
process.exit(1);
}

console.log(storeInstanceResult.message);
process.exit(0);
}

( async () => {
await main();
})();

0 comments on commit 182e4b5

Please sign in to comment.