-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91d3294
commit 05ef28f
Showing
8 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { defineEventHandler } from "#imports"; | ||
import { s3Storage, getKey, normalizeKey } from "#s3"; | ||
import { storage, getKey, normalizeKey } from "#s3"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const key = getKey(event); | ||
|
||
const normalizedKey = normalizeKey(key); | ||
|
||
await s3Storage.removeItem(normalizedKey); | ||
await storage.removeItem(normalizedKey); | ||
|
||
return "ok"; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { defineEventHandler } from "#imports"; | ||
import { s3Storage, getKey, normalizeKey } from "#s3"; | ||
import { storage, getKey, normalizeKey } from "#s3"; | ||
import type { H3Event } from "h3"; | ||
|
||
export default defineEventHandler((event: H3Event) => { | ||
const key = getKey(event); | ||
|
||
const normalizedKey = normalizeKey(key); | ||
|
||
return s3Storage.getItemRaw(normalizedKey, { event }); | ||
return storage.getItemRaw(normalizedKey, { event }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./s3"; | ||
export * from "./key"; | ||
export * from "./storage"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useRuntimeConfig } from "#imports"; | ||
import { s3Storage } from "./s3"; | ||
import { createStorage } from "unstorage"; | ||
import fsLiteDriver from "unstorage/drivers/fs-lite"; | ||
import type { Storage } from "unstorage"; | ||
|
||
const config = useRuntimeConfig(); | ||
|
||
let storage: Storage; | ||
|
||
if (config.s3.driver === "s3") { | ||
storage = s3Storage; | ||
} else if (config.s3.driver === "fs") { | ||
storage = createStorage({ | ||
driver: fsLiteDriver({ base: "./uploads" }), | ||
}); | ||
} | ||
|
||
export { storage }; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.