Skip to content

Commit 968587e

Browse files
Merge pull request #96 from microsoftgraph/Update-Guidance-For-Download-As-Binary
Have enum for ResponseType and Update README.md with download as binary example
2 parents 479a463 + 02a94a4 commit 968587e

File tree

15 files changed

+83
-26
lines changed

15 files changed

+83
-26
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,19 @@ You can pass in additional request headers, either individually or in a dictiona
241241
````
242242

243243
### .responseType()
244-
To set a custom response type, use the `.responseType(string)` method. To see an example, check the [browser sample](samples/browser/index.html) that downloads an image and displays it in an `<img>` element.
244+
To set a custom response type, use the `.responseType(<ResponseType>)` method. Refer [ResponseType.ts](./src/ResponseType.ts) for available options.
245+
````js
246+
client
247+
.api(`/me/drive/root/children/${fileName}/content`)
248+
.responseType(MicrosoftGraph.ResponseType.BLOB)
249+
.get()
250+
.then((res) => {
251+
console.log("Downloaded..!!");
252+
})
253+
.catch((err) => {
254+
throw err;
255+
});
256+
````
245257

246258
## Running node samples
247259
You can run and debug the node samples found under [./samples/node/node-sample.js](./samples/node/node-sample.js) by running the *Run node samples* configuration from the **Debug** (Ctrl + Shift + D) menu in Visual Studio Code. Alternately, you can run the node samples from the CLI by entering `node ./samples/node/node-sample.js` (assuming you are at the root of this repo). You'll need to rename the *secrets.example.json* file to *secrets.json* and add a valid access token to it. You can get an access token by doing the following:

lib/graph-js-sdk-web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/GraphRequest.js

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/GraphRequest.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/ResponseType.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export declare enum ResponseType {
2+
ARRAYBUFFER = "arraybuffer",
3+
BLOB = "blob",
4+
DOCUMENT = "document",
5+
JSON = "json",
6+
STREAM = "stream",
7+
TEXT = "text"
8+
}

lib/src/ResponseType.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/ResponseType.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/common.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export declare class Client {
88
export * from "./GraphRequest";
99
export * from "./common";
1010
export * from "./ResponseHandler";
11+
export * from "./ResponseType";

lib/src/index.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)