Persist media uploads outside public/ to survive rebuilds and redeploys
Local Build and Deploy / deploy (push) Successful in 1m9s
Local Build and Deploy / deploy (push) Successful in 1m9s
Move media storage from public/assets/images/media to storage/media (outside Git and public/), so uploaded images, favicons and logos are preserved across rebuilds and git clean. Add a shared media-storage helper, update the upload/serve actions and API routes, and gitignore storage/.
This commit is contained in:
1 parent
0d82f1325e
commit
1bbbf6e5a4
693 files changed
+38
-19
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import path from "node:path";
|
||||
|
||||
/**
|
||||
* Persistent media root. Lives outside `public/` and outside Git so uploads
|
||||
* survive rebuilds, redeploys and `git clean`. Served through /api/media.
|
||||
*/
|
||||
export const MEDIA_ROOT = path.resolve(process.cwd(), "storage", "media");
|
||||
|
||||
export function resolveMediaPath(...segments: string[]): string {
|
||||
const target = path.resolve(MEDIA_ROOT, ...segments);
|
||||
if (target !== MEDIA_ROOT && !target.startsWith(MEDIA_ROOT + path.sep)) {
|
||||
throw new Error("Invalid media path");
|
||||
}
|
||||
return target;
|
||||
}
|
||||
Reference in new issue
Block a user