@medusajs/file-local-next 0.0.3-snapshot-20240719133408 → 0.0.3-snapshot-20240724143042
Sign up to get free protection for your applications and to get access to all the features.
@@ -34,8 +34,8 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
34
34
|
const baseDir = file.access === "public" ? this.uploadDir_ : this.privateUploadDir_;
|
35
35
|
const dir = await this.ensureDirExists(baseDir, parsedFilename.dir);
|
36
36
|
const fileKey = path_1.default.join(parsedFilename.dir,
|
37
|
-
// We
|
38
|
-
`${
|
37
|
+
// We prepend "private" to the file key so deletions and presigned URLs can know which folder to look into
|
38
|
+
`${file.access === "public" ? "" : "private-"}${Date.now()}-${parsedFilename.base}`);
|
39
39
|
const filePath = this.getUploadFilePath(baseDir, fileKey);
|
40
40
|
const fileUrl = this.getUploadFileUrl(fileKey);
|
41
41
|
const content = Buffer.from(file.content, "binary");
|
@@ -46,7 +46,7 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
46
46
|
};
|
47
47
|
}
|
48
48
|
async delete(file) {
|
49
|
-
const baseDir = file.fileKey.
|
49
|
+
const baseDir = file.fileKey.startsWith("private-")
|
50
50
|
? this.privateUploadDir_
|
51
51
|
: this.uploadDir_;
|
52
52
|
const filePath = this.getUploadFilePath(baseDir, file.fileKey);
|
@@ -62,7 +62,7 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
62
62
|
// For private files, we simply return the file path, which can then be loaded manually by the backend.
|
63
63
|
// The local file provider doesn't support presigned URLs for private files.
|
64
64
|
async getPresignedDownloadUrl(file) {
|
65
|
-
const isPrivate = file.fileKey.
|
65
|
+
const isPrivate = file.fileKey.startsWith("private-");
|
66
66
|
const baseDir = isPrivate ? this.privateUploadDir_ : this.uploadDir_;
|
67
67
|
const filePath = this.getUploadFilePath(baseDir, file.fileKey);
|
68
68
|
try {
|
@@ -89,4 +89,4 @@ class LocalFileService extends utils_1.AbstractFileProviderService {
|
|
89
89
|
}
|
90
90
|
exports.LocalFileService = LocalFileService;
|
91
91
|
LocalF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lLENBQUMsT0FBZSxFQUFFLE9BQWU7UUFDNUQsTUFBTSxZQUFZLEdBQUcsY0FBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsT0FBTyxDQUFDLENBQUE7UUFDaEQsSUFBSSxDQUFDO1lBQ0gsTUFBTSxrQkFBRSxDQUFDLE1BQU0sQ0FBQyxZQUFZLEVBQUUsa0JBQUUsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLENBQUE7UUFDbEQsQ0FBQztRQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUM7WUFDWCxNQUFNLGtCQUFFLENBQUMsS0FBSyxDQUFDLFlBQVksRUFBRSxFQUFFLFNBQVMsRUFBRSxJQUFJLEVBQUUsQ0FBQyxDQUFBO1FBQ25ELENBQUM7UUFFRCxPQUFPLFlBQVksQ0FBQTtJQUNyQixDQUFDOztBQWxISCw0Q0FtSEM7QUFsSFEsMkJBQVUsR0FBRyxTQUFTLEFBQVosQ0FBWSJ9
|
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-20240724143042",
|
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-20240724143042"
|
33
33
|
},
|
34
34
|
"keywords": [
|
35
35
|
"medusa-plugin",
|