Permalink
Browse files

Merge pull request #115 from timonus/gif-support

Animated GIF support.
  • Loading branch information...
2 parents f2a5d6e + efb0bf0 commit e3183d1765904f17ee0fd236b3994f2ef79b93b8 @rahul-malik rahul-malik committed on GitHub Dec 7, 2016
Showing with 39 additions and 4 deletions.
  1. +19 −0 Pod/Classes/PDKClient.h
  2. +20 −4 Pod/Classes/PDKClient.m
@@ -427,6 +427,25 @@ typedef void (^PDKPinUploadProgress)(CGFloat percentComplete);
andFailure:(PDKClientFailure)failureBlock;
/**
+ * Creates a new pin from a UIImage
+ *
+ * @param imageData Image data to pin
+ * @param link A URL to the source page
+ * @param boardId Id of the board to pin to
+ * @param pinDescription Description of the pin
+ * @param progressBlock Block called periodically as the UIImage uploads
+ * @param successBlock Called when the API call succeeds
+ * @param failureBlock Called when the API call fails
+ */
+- (void)createPinWithImageData:(NSData *)imageData
+ link:(NSURL *)link
+ onBoard:(NSString *)boardId
+ description:(NSString *)pinDescription
+ progress:(PDKPinUploadProgress)progressBlock
+ withSuccess:(PDKClientSuccess)successBlock
+ andFailure:(PDKClientFailure)failureBlock;
+
+/**
* Method used to open a URL. If the URL is a web address, we try to present a SFSafariViewController from the presentingViewController.
* In earlier versions it uses UIApplication's openURL
*/
@@ -609,7 +609,24 @@ - (void)createPinWithImage:(UIImage *)image
description:(NSString *)pinDescription
progress:(PDKPinUploadProgress)progressBlock
withSuccess:(PDKClientSuccess)successBlock
- andFailure:(PDKClientFailure)failureBlock;
+ andFailure:(PDKClientFailure)failureBlock
+{
+ [self createPinWithImageData:UIImageJPEGRepresentation(image, 1.0f)
+ link:link
+ onBoard:boardId
+ description:pinDescription
+ progress:progressBlock
+ withSuccess:successBlock
+ andFailure:failureBlock];
+}
+
+- (void)createPinWithImageData:(NSData *)imageData
+ link:(NSURL *)link
+ onBoard:(NSString *)boardId
+ description:(NSString *)pinDescription
+ progress:(PDKPinUploadProgress)progressBlock
+ withSuccess:(PDKClientSuccess)successBlock
+ andFailure:(PDKClientFailure)failureBlock
{
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
parameters[@"board"] = boardId;
@@ -621,11 +638,10 @@ - (void)createPinWithImage:(UIImage *)image
NSString *path = @"pins/";
NSString *urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
[self POST:urlString parameters:[self signParameters:parameters] constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
- NSData *imageData = UIImageJPEGRepresentation(image, 1.0f);
[formData appendPartWithFileData:imageData
name:@"image"
- fileName:@"myphoto.jpg"
- mimeType:@"image/jpeg"];
+ fileName:@"image"
+ mimeType:@"application/octet-stream"];
} progress:^(NSProgress * _Nonnull uploadProgress) {
if (progressBlock && [uploadProgress totalUnitCount] > 0) {
CGFloat percentComplete = (CGFloat)[uploadProgress completedUnitCount]/(CGFloat)[uploadProgress totalUnitCount];

0 comments on commit e3183d1

Please sign in to comment.