Skip to content

Commit 9228aeb

Browse files
committed
publich files handling
1 parent acb0820 commit 9228aeb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inspatial/cloud",
3-
"version": "0.6.15",
3+
"version": "0.6.16",
44
"license": "Apache-2.0",
55
"exports": {
66
".": "./mod.ts",

src/files/public-files-handler.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ export const publicFilesHandler: PathHandler = {
77
description: "Serve files that were uploaded as public files",
88
match: /^\/files\/(.+)$/,
99
async handler(inCloud, inRequest, inResponse) {
10-
const accountAndFileId = inRequest.path.replace(/^\/files\//, "");
10+
const thumbnail = inRequest.params.get("thumbnail");
11+
const accountAndFileId = inRequest.path.replace(/^\/files\//, "") +
12+
thumbnail
13+
? "/thumb"
14+
: "";
1115
if (!accountAndFileId) {
1216
raiseServerException(404, "File not found");
1317
}
@@ -19,7 +23,10 @@ export const publicFilesHandler: PathHandler = {
1923
raiseServerException(404, "File not found");
2024
}
2125
for await (const item of Deno.readDir(accontFolder)) {
22-
if (item.isFile && item.name.startsWith(fileId)) {
26+
if (
27+
item.isFile &&
28+
item.name.startsWith(`${fileId}${thumbnail ? "-thumb" : ""}.`)
29+
) {
2330
filePath = joinPath(accountId, item.name);
2431
inCloud.inCache.setValue("publicFiles", accountAndFileId, filePath);
2532
break;

0 commit comments

Comments
 (0)