Will
Will

Reputation: 1696

Streaming video URL from Box via iOS SDK

I am using Box's iOS SDK (https://github.com/box/box-ios-sdk-v2) and I am trying to get a URL to stream videos that are uploaded to Box.

I tried using the following method on the BoxFilesResourceManager class, but I do not see any special fields on https://developers.box.com/docs/#folders-folder-object that would get me a streaming URL

- (BoxAPIJSONOperation *)fileInfoWithID:(NSString *)fileID requestBuilder:(BoxFilesRequestBuilder *)builder success:(BoxFileBlock)successBlock failure:(BoxAPIJSONFailureBlock)failureBlock;

The only potential way to get a URL may be for me to get a shared link of the file and try to stream from that, but I hardly doubt that will give me the correct URL

Thanks

Upvotes: 0

Views: 429

Answers (1)

Postolaki
Postolaki

Reputation: 41

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://api.box.com/2.0/files/%@/content", fileId]]];
NSString *bearerToken = [NSString stringWithFormat:@"Bearer %@", accessToken]; // the access tokes must be valid(not expired)
[request addValue:bearerToken forHTTPHeaderField:@"Authorization"];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[conn start];

// NSURLConnection Delegate method 
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"streamable url: %@", response.URL);
}

Upvotes: 2

Related Questions