postiz-app/libraries/helpers/src/utils/read.or.fetch.ts
2025-05-31 21:44:16 +07:00

16 lines
322 B
TypeScript

import { readFileSync } from 'fs';
import axios from 'axios';
export const readOrFetch = async (path: string) => {
if (path.indexOf('http') === 0) {
return (
await axios({
url: path,
method: 'GET',
responseType: 'arraybuffer',
})
).data;
}
return readFileSync(path);
};