Skip to content

Commit

Permalink
Save media shortcodes on upload return.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioEstevao committed Mar 28, 2015
1 parent 2741432 commit 8ff671c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions WordPress/Classes/Networking/MediaServiceRemoteREST.m
Expand Up @@ -51,9 +51,12 @@ - (void)createMedia:(RemoteMedia *)media
NSString *path = media.localURL;
NSString *type = media.mimeType;
NSString *filename = media.file;

NSString *apiPath = [NSString stringWithFormat:@"sites/%@/media/new", blog.dotComID];
NSMutableURLRequest *request = [self.api.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:apiPath relativeToURL:self.api.baseURL] absoluteString] parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
NSMutableURLRequest *request = [self.api.requestSerializer multipartFormRequestWithMethod:@"POST"
URLString:[[NSURL URLWithString:apiPath relativeToURL:self.api.baseURL] absoluteString]
parameters:nil
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
[formData appendPartWithFileURL:url name:@"media[]" fileName:filename mimeType:type error:nil];
} error:nil];
Expand Down Expand Up @@ -125,7 +128,10 @@ - (RemoteMedia *)remoteMediaFromJSONDictionary:(NSDictionary *)jsonMedia
remoteMedia.descriptionText = jsonMedia[@"description"];
remoteMedia.height = jsonMedia[@"height"];
remoteMedia.width = jsonMedia[@"width"];
remoteMedia.exif = jsonMedia[@"exif"];
remoteMedia.exif = jsonMedia[@"exif"];
if (jsonMedia[@"videopress_guid"]) {
remoteMedia.shortcode = jsonMedia[@"videopress_guid"];
}
return remoteMedia;
}

Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Networking/Remote Objects/RemoteMedia.h
Expand Up @@ -14,6 +14,7 @@
@property (nonatomic, strong) NSString * descriptionText;
@property (nonatomic, strong) NSNumber * height;
@property (nonatomic, strong) NSNumber * width;
@property (nonatomic, strong) NSString * shortcode;
@property (nonatomic, strong) NSDictionary * exif;

@end
1 change: 1 addition & 0 deletions WordPress/Classes/Services/MediaService.m
Expand Up @@ -292,6 +292,7 @@ - (void)updateMedia:(Media *)media withRemoteMedia:(RemoteMedia *)remoteMedia
media.height = remoteMedia.height;
media.width = remoteMedia.width;
//media.exif = remoteMedia.exif;
media.shortcode = remoteMedia.shortcode;
}

- (RemoteMedia *) remoteMediaFromMedia:(Media *)media
Expand Down

0 comments on commit 8ff671c

Please sign in to comment.