MCPcopy Create free account
hub / github.com/GetStream/stream-js / upload

Method upload

src/client.ts:721–741  ·  view source on GitHub ↗
(
    url: string,
    uri: string | File | Buffer | NodeJS.ReadStream,
    name?: string,
    contentType?: string,
    onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
  )

Source from the content-addressed store, hash-verified

719 };
720
721 upload(
722 url: string,
723 uri: string | File | Buffer | NodeJS.ReadStream,
724 name?: string,
725 contentType?: string,
726 onUploadProgress?: (progressEvent: AxiosProgressEvent) => void,
727 ) {
728 const fd = utils.addFileToFormData(uri, name, contentType);
729 return this.doAxiosRequest<FileUploadAPIResponse>('POST', {
730 url,
731 body: fd,
732 headers: fd.getHeaders ? fd.getHeaders() : {}, // node vs browser
733 token: this.getOrCreateToken(),
734 axiosOptions: {
735 timeout: 0,
736 maxContentLength: Infinity,
737 maxBodyLength: Infinity,
738 onUploadProgress,
739 },
740 });
741 }
742
743 /**
744 * Shorthand function for get request

Callers 4

images.jsFile · 0.45
files.jsFile · 0.45
test.tsFile · 0.45
client_test.jsFile · 0.45

Calls 1

getOrCreateTokenMethod · 0.95

Tested by

no test coverage detected