Skip to content

Commit

Permalink
feat: extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
3mcd committed Jul 18, 2022
1 parent f823199 commit dadf1aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ function createStorageKey(length = 32) {
return key;
}

async function uploadToStorage(path: string) {
async function uploadToStorage(path: string, suffix = "") {
const key = createStorageKey();
const stream = createReadStream(path);
return storageProvider.upload(key, stream);
return storageProvider.upload(`${key}${suffix}`, stream);
}

function spawnPagedProcess(inputFile: string, outputFile: string) {
Expand All @@ -58,7 +58,7 @@ async function convertToPDF(html: string) {
const tempOutputFilePath = temporaryFile({ extension: ".pdf" });
await writeFile(tempInputFilePath, html);
await spawnPagedProcess(tempInputFilePath, tempOutputFilePath);
return uploadToStorage(tempOutputFilePath);
return uploadToStorage(tempOutputFilePath, ".pdf");
}
const app = new Koa();
const router = new Router();
Expand Down

0 comments on commit dadf1aa

Please sign in to comment.