This repository was archived by the owner on Aug 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -295,6 +295,14 @@ export class File extends QueryableInstance {
295295 return new File ( this , "$value" ) . get ( new BufferFileParser ( ) , { headers : { "binaryStringResponseBody" : "true" } } ) ;
296296 }
297297
298+ /**
299+ * Gets the contents of a file as an ArrayBuffer, works in Node.js
300+ */
301+ public getJSON ( ) : Promise < any > {
302+
303+ return new File ( this , "$value" ) . get ( new JSONFileParser ( ) , { headers : { "binaryStringResponseBody" : "true" } } ) ;
304+ }
305+
298306 /**
299307 * Sets the content of a file, for large files use setContentChunked
300308 *
@@ -434,6 +442,13 @@ export class BlobFileParser implements ODataParser<any, Blob> {
434442 }
435443}
436444
445+ export class JSONFileParser implements ODataParser < any , any > {
446+
447+ public parse ( r : Response ) : Promise < any > {
448+ return r . json ( ) ;
449+ }
450+ }
451+
437452export class BufferFileParser implements ODataParser < any , ArrayBuffer > {
438453
439454 public parse ( r : any ) : Promise < ArrayBuffer > {
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export {
1414 TextFileParser ,
1515 BlobFileParser ,
1616 BufferFileParser ,
17+ JSONFileParser ,
1718 ChunkedFileUploadProgressData
1819} from "./files" ;
1920
You can’t perform that action at this time.
0 commit comments