Skip to content
This repository was archived by the owner on Apr 18, 2023. It is now read-only.

Commit f4d0493

Browse files
authored
Merge pull request #26 from microsoftgraph/vidadhee/Readme
Vidadhee/readme
2 parents f0274de + 2b20381 commit f4d0493

File tree

6 files changed

+82
-11
lines changed

6 files changed

+82
-11
lines changed

Docs/Tasks/LargeFileUpload.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Large File Upload Task - Uploading large files to OneDrive.
2+
3+
This task can be used for of onedrive's [Upload large files with an upload session](https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession) feature.
4+
5+
## Creating the client instance
6+
7+
Refer [this part](https://github.com/microsoftgraph/msgraph-sdk-objc#how-to-use-sdk) of Readme file and follow the steps to create an HTTP Client configured with authentication provider.
8+
9+
## Uploading the file
10+
11+
Once you have an MSHTTPClient instance you just need to use `MSGraphOneDriveLargeFileUploadTask` class in below fashion to successfully upload the file:
12+
```
13+
//Get file url
14+
NSURL *fileURL = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"LargeFileUploadResource" ofType:@".bmp"]];
15+
NSError *fileReadError;
16+
//Create file data
17+
NSData *fileData = [NSData dataWithContentsOfFile:[fileURL absoluteString] options:kNilOptions error:&fileReadError];
18+
if(!fileReadError)
19+
{
20+
//Create an MSGraphOneDriveLargeFileUploadTask.
21+
[MSGraphOneDriveLargeFileUploadTask createOneDriveLargeFileUploadTaskWithHTTPClient:httpClient fileData:fileData fileName:@"LargeFile" filePath:@"Documents" andChunkSize:5*1024*1024 withCompletion:^(MSGraphOneDriveLargeFileUploadTask *fileUploadTask, NSData *data, NSURLResponse *response, NSError *error) {
22+
if(error)
23+
{
24+
//Handle any error which might have occurred during upload session creation
25+
NSLog(@"There was some error while creating upload session %@",error);
26+
}
27+
else if([(NSHTTPURLResponse *)response statusCode] == 200 && fileUploadTask)
28+
{
29+
//Use successfully created fileUploadTask to upload the file.
30+
[fileUploadTask uploadWithCompletion:^(NSData *data, NSURLResponse *response, NSError *error) {
31+
if(!error)
32+
{
33+
NSLog(@"Response from server %@",[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]);
34+
}
35+
}];
36+
}
37+
}];
38+
}
39+
```
40+

Docs/Tasks/PageIterator.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# PageIterator
2+
3+
This task enables the consumers of the SDK to iterate through paged collections in a simplified manner.
4+
5+
To understand the objectives and requirements for this feature in more detail, please refer [PageIterator](https://github.com/microsoftgraph/msgraph-sdk-design/blob/master/tasks/PageIteratorTask.md).
6+
7+
## Usage
8+
9+
### Creating the client instance
10+
11+
Refer [this part](https://github.com/microsoftgraph/msgraph-sdk-objc#how-to-use-sdk) of Readme file and follow the steps to create an HTTP Client configured with authentication provider.
12+
13+
### Using the MSPageIterator class
14+
//Create a request for the API which will have paged collection response. For example:/me/messages
15+
NSMutableURLRequest *messageRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/me/messages?$top=10"]]];
16+
17+
//Create a data task to get the initial response
18+
MSURLSessionDataTask *dataTask = [httpClient dataTaskWithRequest:messageRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
19+
if(!error){
20+
__block int itemCount = 0;
21+
//If there is no error, use MSPageIterator instance to perform intra-page iteration and then onwards inter-page iteration.
22+
MSPageIterator *pageIterator = [[MSPageIterator alloc] initWithData:data client:httpClient andIteratorBlock:^(NSDictionary *itemDictionary, BOOL *stop) {
23+
//The itemDictionary in callback block corresponds to individual message in the list.
24+
if(itemCount == 21){
25+
//You can stop the iteration in below fashion.
26+
*stop = TRUE;
27+
}
28+
itemCount++;
29+
}];
30+
//Start the iteration
31+
[pageIterator iterate];
32+
}
33+
}];
34+
[dataTask execute];
35+
```

MSGraphClientSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |s|
33

44
s.name = "MSGraphClientSDK"
5-
s.version = "0.1.3"
5+
s.version = "1.0.0"
66
s.summary = "Microsoft Graph ObjC SDK."
77

88
s.description = <<-DESC

MSGraphClientSDK/MSGraphClientSDK/Common/MSConstants.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
NSString *const MSGraphGermanyBaseURL = @"https://graph.microsoft.de/v1.0";
1111

1212
NSString *const MSHeaderSdkVersion = @"SdkVersion";
13-
NSString *const MSGraphiOSSdkVersionHeaderPrefix = @"graph-objc-ios-";
14-
NSString *const MSGraphMacSdkVersionHeaderPrefix = @"graph-objc-mac-";
13+
NSString *const MSGraphiOSSdkVersionHeaderPrefix = @"graph-objc-ios/";
14+
NSString *const MSGraphMacSdkVersionHeaderPrefix = @"graph-objc-mac/";
1515

1616

1717
NSString *const MSErrorDomain = @"com.microsoft.graph.errors";

MSGraphClientSDK/MSGraphClientSDK/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.1.3</string>
18+
<string>1.0.0</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
# Microsoft Graph SDK for ObjC
33

44

5-
This client library is a release candidate and is still in preview status - please continue to provide feedback as we iterate towards a production supported library.
6-
7-
8-
9-
This library supports both iOS and MacOS platforms.
10-
11-
5+
Get started with the Microsoft Graph SDK for ObjectiveC by integrating it into your iOS and MacOS applications!
126

137
## Installation
148

@@ -166,3 +160,5 @@ And that's it. You have now successfully made call to graph server asking inform
166160
## Usage Resources
167161

168162
* [Batching](/Docs/Content/Batching.md)
163+
* [Page Iterator](/Docs/Tasks/PageIterator.md)
164+
* [Large File Upload Task](/Docs/Tasks/LargeFileUpload.md)

0 commit comments

Comments
 (0)