Skip to content

Commit

Permalink
Update original file url reference to use authenticated_download_url (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jdizoglio authored Jun 22, 2018
1 parent 9c99fd6 commit b78483c
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 36 deletions.
1 change: 0 additions & 1 deletion BoxContentSDK/BoxContentSDK/BOXContentSDKConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ extern BOXCollaborationRole *const BOXCollaborationRoleUploader;
// Representation Type
typedef NSString BOXRepresentationType;
extern BOXRepresentationType *const BOXRepresentationTypeOriginal;
extern BOXRepresentationType *const BOXRepresentationTypeSecondaryOriginal;
extern BOXRepresentationType *const BOXRepresentationTypePDF;
extern BOXRepresentationType *const BOXRepresentationTypeMP4;
extern BOXRepresentationType *const BOXRepresentationTypeMP3;
Expand Down
1 change: 0 additions & 1 deletion BoxContentSDK/BoxContentSDK/BOXContentSDKConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@

// Representation Type
BOXRepresentationType *const BOXRepresentationTypeOriginal = @"original";
BOXRepresentationType *const BOXRepresentationTypeSecondaryOriginal = @"secondary original";
BOXRepresentationType *const BOXRepresentationTypePDF = @"pdf";
BOXRepresentationType *const BOXRepresentationTypeMP4 = @"mp4";
BOXRepresentationType *const BOXRepresentationTypeMP3 = @"mp3";
Expand Down
6 changes: 0 additions & 6 deletions BoxContentSDK/BoxContentSDK/Models/BOXFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@
*/
@property (nonatomic, readwrite, strong) NSArray *representations;

/**
* Url available to download original content.
* Warning: file exists only if canDownload is true
*/
@property (nonatomic, readwrite, strong) NSURL *downloadUrl;

/**
* Url available to download or preview original content.
* Warning: file url exists if canDownload or canPreview is true
Expand Down
19 changes: 2 additions & 17 deletions BoxContentSDK/BoxContentSDK/Models/BOXFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,7 @@ - (instancetype)initWithJSON:(NSDictionary *)JSONResponse
if (lock && ![lock isKindOfClass:[NSNull class]]) {
self.lock = [[BOXFileLock alloc] initWithJSON:lock];
}

NSString *downloadURLString = [NSJSONSerialization box_ensureObjectForKey:BOXAPIObjectKeyDownloadURL
inDictionary:JSONResponse
hasExpectedType:[NSString class]
nullAllowed:NO];
if (downloadURLString.length > 0) {
self.downloadUrl = [NSURL URLWithString:downloadURLString];
}


NSString *authenticatedDownloadURLString = [NSJSONSerialization box_ensureObjectForKey:BOXAPIObjectKeyAuthenticatedDownloadURL
inDictionary:JSONResponse
hasExpectedType:[NSString class]
Expand All @@ -112,16 +104,9 @@ - (instancetype)initWithJSON:(NSDictionary *)JSONResponse
}

// Add the original content url to self.representations as BOXRepresentationRequestOriginal for convenience
if (self.downloadUrl.absoluteString.length > 0) {
BOXRepresentation *representation = [[BOXRepresentation alloc] init];
representation.type = BOXRepresentationTypeOriginal;
representation.contentURL = self.downloadUrl;
representation.status = BOXRepresentationStatusSuccess;
[tempRepresentations addObject:representation];
}
if (self.authenticatedDownloadUrl.absoluteString.length > 0) {
BOXRepresentation *representation = [[BOXRepresentation alloc] init];
representation.type = BOXRepresentationTypeSecondaryOriginal;
representation.type = BOXRepresentationTypeOriginal;
representation.contentURL = self.authenticatedDownloadUrl;
representation.status = BOXRepresentationStatusSuccess;
[tempRepresentations addObject:representation];
Expand Down
6 changes: 1 addition & 5 deletions BoxContentSDK/BoxContentSDK/Requests/BOXFileRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
a file, set the options for each type.
- BOXRepresentationRequestOriginal: Request original content url with file information request
Reference the reponse field 'download_url' to download original content when file
Reference the reponse field 'authenticated_download_url' to download original content when file
has download permissions are owner, co-owner, editor, viewer uploader, viewer
- BOXRepresentationRequestAuthenticatedOriginal: Request original content url for
Reference the reponse field 'authenticated_download_url' to access original content when file
has download permissions are owner, co-owner, editor, viewer uploader, viewer, preview and preview uploader permission
- BOXRepresentationRequestAllRepresentations: If permissions allow retrieve representations for thumbnails, preview representations for the given file
- BOXRepresentationRequestHighDefinitionVideo: Request video representions if available for the given file
- BOXRepresentationRequestThumbnailRepresentation: Request thumbnail representions if available for the given file
Expand All @@ -28,7 +25,6 @@
*/
typedef NS_ENUM(NSUInteger, BOXRepresentationRequestOptions) {
BOXRepresentationRequestOriginal,
BOXRepresentationRequestAuthenticatedOriginal,
BOXRepresentationRequestAllRepresentations,
BOXRepresentationRequestHighDefinitionVideo,
BOXRepresentationRequestThumbnailRepresentation,
Expand Down
7 changes: 1 addition & 6 deletions BoxContentSDK/BoxContentSDK/Requests/BOXFileRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ - (BOXAPIOperation *)createOperation
// You can download the file has owner, co-owner, editor, viewer uploader, viewer permissions.
if ([self.representationsRequested containsObject:@(BOXRepresentationRequestOriginal)]) {
[self.representationsRequested removeObject:@(BOXRepresentationRequestOriginal)];
fieldString = [fieldString stringByAppendingFormat:@",%@", BOXAPIObjectKeyDownloadURL];
}
if ([self.representationsRequested containsObject:@(BOXRepresentationRequestAuthenticatedOriginal)]) {
fieldString = [fieldString stringByAppendingFormat:@",%@", BOXAPIObjectKeyAuthenticatedDownloadURL];
}
if ([self.representationsRequested count] > 0) {
Expand Down Expand Up @@ -257,9 +254,7 @@ - (NSString *)formatRepresentationRequestHeader
if ([self.representationsRequested containsObject:@(BOXRepresentationRequestOriginal)]) {
[self.representationsRequested removeObject:@(BOXRepresentationRequestOriginal)];
}
if ([self.representationsRequested containsObject:@(BOXRepresentationRequestAuthenticatedOriginal)]) {
[self.representationsRequested removeObject:@(BOXRepresentationRequestAuthenticatedOriginal)];
}

if ([self.representationsRequested count] == 0) {
return nil;
}
Expand Down

0 comments on commit b78483c

Please sign in to comment.