postio / libraries /helpers /src /utils /read.or.fetch.ts
Leon4gr45's picture
Upload folder using huggingface_hub (part 9)
57aa51e verified
Raw
History Blame Contribute Delete
322 Bytes
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);
};