@medusajs/file-local-next 0.0.3-snapshot-20240728083710 → 0.0.3-snapshot-20240730111259
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"local-file.d.ts","sourceRoot":"","sources":["../../src/services/local-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,EAAE,2BAA2B,EAAe,MAAM,iBAAiB,CAAA;AAI1E,qBAAa,gBAAiB,SAAQ,2BAA2B;IAC/D,MAAM,CAAC,UAAU,SAAY;IAC7B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAA;IAC5B,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAA;IACnC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAA;gBAEjB,CAAC,KAAA,EAAE,OAAO,EAAE,uBAAuB;
|
1
|
+
{"version":3,"file":"local-file.d.ts","sourceRoot":"","sources":["../../src/services/local-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,EAAE,2BAA2B,EAAe,MAAM,iBAAiB,CAAA;AAI1E,qBAAa,gBAAiB,SAAQ,2BAA2B;IAC/D,MAAM,CAAC,UAAU,SAAY;IAC7B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAA;IAC5B,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAA;IACnC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAA;gBAEjB,CAAC,KAAA,EAAE,OAAO,EAAE,uBAAuB;IAazC,MAAM,CACV,IAAI,EAAE,SAAS,CAAC,qBAAqB,GACpC,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAqCrC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5D,uBAAuB,CAC3B,IAAI,EAAE,SAAS,CAAC,kBAAkB,GACjC,OAAO,CAAC,MAAM,CAAC;IAkBlB,OAAO,CAAC,iBAAiB,CAExB;IAED,OAAO,CAAC,gBAAgB,CAIvB;YAEa,eAAe;CAU9B"}
|
@@ -19,8 +19,12 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
19
19
|
return baseUrl.href;
|
20
20
|
};
|
21
21
|
this.uploadDir_ = options?.upload_dir || path_1.default.join(process.cwd(), "static");
|
22
|
+
// Since there is no way to serve private files through a static server, we simply place them in `static`.
|
23
|
+
// This means that the files will be available publicly if the filename is known. Since the local file provider
|
24
|
+
// is for development only, this shouldn't be an issue. If you really want to use it in production (and you shouldn't)
|
25
|
+
// You can change the private upload dir to `/private` but none of the functionalities where you use a presigned URL will work.
|
22
26
|
this.privateUploadDir_ =
|
23
|
-
options?.private_upload_dir || path_1.default.join(process.cwd(), "
|
27
|
+
options?.private_upload_dir || path_1.default.join(process.cwd(), "static");
|
24
28
|
this.backendUrl_ = options?.backend_url || "http://localhost:9000/static";
|
25
29
|
}
|
26
30
|
async upload(file) {
|
@@ -59,8 +63,7 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
59
63
|
}
|
60
64
|
return;
|
61
65
|
}
|
62
|
-
//
|
63
|
-
// The local file provider doesn't support presigned URLs for private files.
|
66
|
+
// The local file provider doesn't support presigned URLs for private files (i.e files not placed in /static).
|
64
67
|
async getPresignedDownloadUrl(file) {
|
65
68
|
const isPrivate = file.fileKey.startsWith("private-");
|
66
69
|
const baseDir = isPrivate ? this.privateUploadDir_ : this.uploadDir_;
|
@@ -71,9 +74,6 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
71
74
|
catch {
|
72
75
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `File with key ${file.fileKey} not found`);
|
73
76
|
}
|
74
|
-
if (isPrivate) {
|
75
|
-
return filePath;
|
76
|
-
}
|
77
77
|
return this.getUploadFileUrl(file.fileKey);
|
78
78
|
}
|
79
79
|
async ensureDirExists(baseDir, dirPath) {
|
@@ -89,4 +89,4 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
89
89
|
}
|
90
90
|
exports.LocalFileService = LocalFileService;
|
91
91
|
LocalFileService.identifier = "localfs";
|
92
|
-
//# sourceMappingURL=data:application/json;base64,
|
92
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtZmlsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zZXJ2aWNlcy9sb2NhbC1maWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUNBLDJDQUEwRTtBQUMxRSwyREFBNEI7QUFDNUIsZ0RBQXVCO0FBRXZCLE1BQWEsZ0JBQWlCLFNBQVEsbUNBQTJCO0lBTS9ELFlBQVksQ0FBQyxFQUFFLE9BQWdDO1FBQzdDLEtBQUssRUFBRSxDQUFBO1FBd0ZELHNCQUFpQixHQUFHLENBQUMsT0FBZSxFQUFFLE9BQWUsRUFBRSxFQUFFO1lBQy9ELE9BQU8sY0FBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsT0FBTyxDQUFDLENBQUE7UUFDcEMsQ0FBQyxDQUFBO1FBRU8scUJBQWdCLEdBQUcsQ0FBQyxPQUFlLEVBQUUsRUFBRTtZQUM3QyxNQUFNLE9BQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUE7WUFDekMsT0FBTyxDQUFDLFFBQVEsR0FBRyxjQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxRQUFRLEVBQUUsT0FBTyxDQUFDLENBQUE7WUFDdkQsT0FBTyxPQUFPLENBQUMsSUFBSSxDQUFBO1FBQ3JCLENBQUMsQ0FBQTtRQS9GQyxJQUFJLENBQUMsVUFBVSxHQUFHLE9BQU8sRUFBRSxVQUFVLElBQUksY0FBSSxDQUFDLElBQ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0JBQWdCLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQzVDLENBQUM7SUFZTyxLQUFLLENBQUMsZUFBZSxDQUFDLE9BQWUsRUFBRSxPQUFlO1FBQzVELE1BQU0sWUFBWSxHQUFHLGNBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLE9BQU8sQ0FBQyxDQUFBO1FBQ2hELElBQUksQ0FBQztZQUNILE1BQU0sa0JBQUUsQ0FBQyxNQUFNLENBQUMsWUFBWSxFQUFFLGtCQUFFLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxDQUFBO1FBQ2xELENBQUM7UUFBQyxPQUFPLENBQUMsRUFBRSxDQUFDO1lBQ1gsTUFBTSxrQkFBRSxDQUFDLEtBQUssQ0FBQyxZQUFZLEVBQUUsRUFBRSxTQUFTLEVBQUUsSUFBSSxFQUFFLENBQUMsQ0FBQTtRQUNuRCxDQUFDO1FBRUQsT0FBTyxZQUFZLENBQUE7SUFDckIsQ0FBQzs7QUFsSEgsNENBbUhDO0FBbEhRLDJCQUFVLEdBQUcsU0FBUyxBQUFaLENBQVkifQ==
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/file-local-next",
|
3
|
-
"version": "0.0.3-snapshot-
|
3
|
+
"version": "0.0.3-snapshot-20240730111259",
|
4
4
|
"description": "Local filesystem file storage for Medusa",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"repository": {
|
@@ -29,7 +29,7 @@
|
|
29
29
|
"typescript": "^5.3.3"
|
30
30
|
},
|
31
31
|
"dependencies": {
|
32
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
32
|
+
"@medusajs/utils": "1.12.0-snapshot-20240730111259"
|
33
33
|
},
|
34
34
|
"keywords": [
|
35
35
|
"medusa-plugin",
|