mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Fix media code, clean up old types
This commit is contained in:
parent
852efaea50
commit
0e4d6b401c
34 changed files with 137 additions and 1204 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import type { ConfigType } from "~classes/configmanager";
|
||||
import type { Attachment } from "@prisma/client";
|
||||
import type { ConfigType } from "config-manager";
|
||||
import { MediaBackendType } from "media-manager";
|
||||
import type { APIAsyncAttachment } from "~types/entities/async_attachment";
|
||||
import type { APIAttachment } from "~types/entities/attachment";
|
||||
|
||||
|
|
@ -56,11 +57,13 @@ export const attachmentToAPI = (
|
|||
};
|
||||
};
|
||||
|
||||
export const getUrl = (hash: string, config: ConfigType) => {
|
||||
if (config.media.backend === "local") {
|
||||
return `${config.http.base_url}/media/${hash}`;
|
||||
} else if (config.media.backend === "s3") {
|
||||
return `${config.s3.public_url}/${hash}`;
|
||||
export const getUrl = (name: string, config: ConfigType) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
||||
if (config.media.backend === MediaBackendType.LOCAL) {
|
||||
return `${config.http.base_url}/media/${name}`;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
|
||||
} else if (config.media.backend === MediaBackendType.S3) {
|
||||
return `${config.s3.public_url}/${name}`;
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue