zephyr-agent
Version:
Zephyr plugin agent
31 lines (30 loc) • 875 B
JavaScript
import "node:module";
import { ZeErrors, ZephyrError } from "../errors/index.mjs";
import { makeRequest } from "./http-request.mjs";
async function uploadFile({ hash, asset }, { EDGE_URL, jwt }) {
const type = 'file';
const options = {
method: 'POST',
headers: {
'x-file-size': asset.size.toString(),
'x-file-path': asset.path,
can_write_jwt: jwt,
'Content-Type': 'application/octet-stream'
}
};
const [ok, cause] = await makeRequest({
path: '/upload',
base: EDGE_URL,
query: {
type,
hash,
filename: asset.path
}
}, options, asset.buffer);
if (!ok) throw new ZephyrError(ZeErrors.ERR_FAILED_UPLOAD, {
type: 'file',
cause
});
}
export { uploadFile };
//# sourceMappingURL=upload-file.mjs.map