Skip to content

Commit 59eb0be

Browse files
authored
Merge pull request #66 from mario-mestrovic/master
Fixed missing extension
2 parents 45ede77 + 5170d02 commit 59eb0be

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ function getServiceBaseUrl(config: Config) {
3030
);
3131
}
3232

33+
function getFileName(path: string, file: StrapiFile) {
34+
return `${trimParam(path)}/${file.hash}${file.ext}`;
35+
}
36+
3337
function makeBlobServiceClient(config: Config) {
3438
const account = trimParam(config.account);
3539
const accountKey = trimParam(config.accountKey);
@@ -52,9 +56,7 @@ async function handleUpload(
5256
): Promise<void> {
5357
const serviceBaseURL = getServiceBaseUrl(config);
5458
const containerClient = blobSvcClient.getContainerClient(trimParam(config.containerName));
55-
const client = containerClient.getBlockBlobClient(
56-
`${trimParam(config.defaultPath)}/${file.hash}`
57-
);
59+
const client = containerClient.getBlockBlobClient(getFileName(config.defaultPath, file));
5860
const options = {
5961
blobHTTPHeaders: { blobContentType: file.mime },
6062
};
@@ -76,7 +78,7 @@ async function handleDelete(
7678
file: StrapiFile
7779
): Promise<void> {
7880
const containerClient = blobSvcClient.getContainerClient(trimParam(config.containerName));
79-
const client = containerClient.getBlobClient(`${trimParam(config.defaultPath)}/${file.hash}`);
81+
const client = containerClient.getBlobClient(getFileName(config.defaultPath, file));
8082
await client.delete();
8183
file.url = client.url;
8284
}

0 commit comments

Comments
 (0)