MCPcopy
hub / github.com/remotely-save/remotely-save / readFile

Method readFile

pro/src/fsBox.ts:836–863  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

834 }
835
836 async readFile(key: string): Promise<ArrayBuffer> {
837 await this._init();
838
839 const cachedEntity = this.keyToBoxEntity[key];
840 const fileID = cachedEntity?.id;
841 if (cachedEntity === undefined || fileID === undefined) {
842 throw Error(`no fileID found for key=${key}`);
843 }
844
845 const res1 = await fetch(
846 `https://api.box.com/2.0/files/${fileID}/content`,
847 {
848 method: "GET",
849 headers: {
850 Authorization: `Bearer ${await this._getAccessToken()}`,
851 },
852 }
853 );
854 if (res1.status !== 200) {
855 throw Error(
856 `Cannot download file ${key} with id ${fileID}. Response header=${JSON.stringify(
857 res1.headers
858 )}`
859 );
860 }
861 const res2 = await res1.arrayBuffer();
862 return res2;
863 }
864
865 async rename(key1: string, key2: string): Promise<void> {
866 throw new Error("Method not implemented.");

Callers 3

mergeFileFunction · 0.45

Calls 2

_initMethod · 0.95
_getAccessTokenMethod · 0.95

Tested by

no test coverage detected