Skip to content

Commit

Permalink
Merge pull request #66 from mario-mestrovic/master
Browse files Browse the repository at this point in the history
Fixed missing extension
  • Loading branch information
jakeFeldman authored Feb 18, 2023
2 parents 45ede77 + 5170d02 commit 59eb0be
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function getServiceBaseUrl(config: Config) {
);
}

function getFileName(path: string, file: StrapiFile) {
return `${trimParam(path)}/${file.hash}${file.ext}`;
}

function makeBlobServiceClient(config: Config) {
const account = trimParam(config.account);
const accountKey = trimParam(config.accountKey);
Expand All @@ -52,9 +56,7 @@ async function handleUpload(
): Promise<void> {
const serviceBaseURL = getServiceBaseUrl(config);
const containerClient = blobSvcClient.getContainerClient(trimParam(config.containerName));
const client = containerClient.getBlockBlobClient(
`${trimParam(config.defaultPath)}/${file.hash}`
);
const client = containerClient.getBlockBlobClient(getFileName(config.defaultPath, file));
const options = {
blobHTTPHeaders: { blobContentType: file.mime },
};
Expand All @@ -76,7 +78,7 @@ async function handleDelete(
file: StrapiFile
): Promise<void> {
const containerClient = blobSvcClient.getContainerClient(trimParam(config.containerName));
const client = containerClient.getBlobClient(`${trimParam(config.defaultPath)}/${file.hash}`);
const client = containerClient.getBlobClient(getFileName(config.defaultPath, file));
await client.delete();
file.url = client.url;
}
Expand Down

0 comments on commit 59eb0be

Please sign in to comment.