mirror of
https://github.com/makeplane/plane.git
synced 2025-12-24 23:59:40 +01:00
- Refactored file upload utilities to use async functions for better handling of file metadata. - Introduced MIME type detection using the file-type library. - Updated file service methods to await metadata retrieval. - Added new dependencies for file-type and updated package.json accordingly. - Removed deprecated file handling code from utils and adjusted imports across services.
26 lines
731 B
TypeScript
26 lines
731 B
TypeScript
// plane imports
|
|
import { API_BASE_URL } from "@plane/constants";
|
|
|
|
/**
|
|
* @description combine the file path with the base URL
|
|
* @param {string} path
|
|
* @returns {string} final URL with the base URL
|
|
*/
|
|
export const getFileURL = (path: string): string | undefined => {
|
|
if (!path) return undefined;
|
|
const isValidURL = path.startsWith("http");
|
|
if (isValidURL) return path;
|
|
return `${API_BASE_URL}${path}`;
|
|
};
|
|
|
|
/**
|
|
* @description this function returns the assetId from the asset source
|
|
* @param {string} src
|
|
* @returns {string} assetId
|
|
*/
|
|
export const getAssetIdFromUrl = (src: string): string => {
|
|
const sourcePaths = src.split("/");
|
|
const assetUrl = sourcePaths[sourcePaths.length - 1];
|
|
return assetUrl ?? "";
|
|
};
|