Skip to content

Commit 66002bd

Browse files
committed
Merge commit 'b5c49540caf930dbaf47a9c0f07cddac6cdd9674' into release/1.14.4
* commit 'b5c49540caf930dbaf47a9c0f07cddac6cdd9674': Parse 1.14.4 (parse-community#1131) Custom File Upload Controller (parse-community#1114) transfer code Bundle check (parse-community#1119) # Conflicts: # Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m
2 parents c99e59e + b5c4954 commit 66002bd

File tree

27 files changed

+206
-42
lines changed

27 files changed

+206
-42
lines changed

LICENSE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
2828
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2929
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3030
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
32+
-----
33+
34+
As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.

PATENTS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ necessarily infringed by the Software standing alone.
3131
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
3232
or contributory infringement or inducement to infringe any patent, including a
3333
cross-claim or counterclaim.
34+
35+
-----
36+
37+
As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.

Parse.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Parse'
3-
s.version = '1.14.3'
3+
s.version = '1.14.4'
44
s.license = { :type => 'BSD', :file => 'LICENSE' }
55
s.homepage = 'https://www.parse.com/'
66
s.summary = 'A library that gives you access to the powerful Parse cloud platform from your iOS/OS X/watchOS/tvOS app.'

Parse.xcodeproj/project.pbxproj

Lines changed: 48 additions & 0 deletions
Large diffs are not rendered by default.

Parse/Internal/File/Controller/PFFileController.m

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#import "PFMacros.h"
2525
#import "PFRESTFileCommand.h"
2626
#import "PFErrorUtilities.h"
27+
#import "Parse.h"
28+
#import "PFFileUploadController.h"
2729

2830
static NSString *const PFFileControllerCacheDirectoryName_ = @"PFFileCache";
2931

@@ -218,21 +220,41 @@ - (NSString *)_temporaryFileDownloadPathForFileState:(PFFileState *)fileState {
218220
return [BFTask taskWithError:error];
219221
}
220222

221-
PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name sessionToken:sessionToken];
222-
@weakify(self);
223-
return [[self.dataSource.commandRunner runFileUploadCommandAsync:command
224-
withContentType:fileState.mimeType
225-
contentSourceFilePath:sourceFilePath
226-
options:PFCommandRunningOptionRetryIfFailed
227-
cancellationToken:cancellationToken
228-
progressBlock:progressBlock] continueWithSuccessBlock:^id(BFTask<PFCommandResult *> *task) {
229-
@strongify(self);
230-
PFCommandResult *result = task.result;
231-
PFFileState *fileState = [[PFFileState alloc] initWithName:result.result[@"name"]
232-
urlString:result.result[@"url"]
233-
mimeType:nil];
234-
return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState];
235-
}];
223+
224+
id<PFFileUploadController> customFileUploadController = Parse.currentConfiguration.fileUploadController;
225+
if (customFileUploadController) {
226+
@weakify(self);
227+
return [[customFileUploadController uploadSourceFilePath:sourceFilePath
228+
fileName:fileState.name
229+
mimeType:fileState.mimeType
230+
sessionToken:sessionToken
231+
cancellationToken:cancellationToken
232+
progressBlock:progressBlock]
233+
continueWithSuccessBlock:^id(BFTask<PFFileUploadResult *> *task) {
234+
@strongify(self);
235+
PFFileUploadResult *result = task.result;
236+
PFFileState *fileState = [[PFFileState alloc] initWithName:result.name
237+
urlString:result.url
238+
mimeType:nil];
239+
return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState];
240+
}];
241+
} else {
242+
PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name sessionToken:sessionToken];
243+
@weakify(self);
244+
return [[self.dataSource.commandRunner runFileUploadCommandAsync:command
245+
withContentType:fileState.mimeType
246+
contentSourceFilePath:sourceFilePath
247+
options:PFCommandRunningOptionRetryIfFailed
248+
cancellationToken:cancellationToken
249+
progressBlock:progressBlock] continueWithSuccessBlock:^id(BFTask<PFCommandResult *> *task) {
250+
@strongify(self);
251+
PFCommandResult *result = task.result;
252+
PFFileState *fileState = [[PFFileState alloc] initWithName:result.result[@"name"]
253+
urlString:result.result[@"url"]
254+
mimeType:nil];
255+
return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState];
256+
}];
257+
}
236258
}
237259

238260
///--------------------------------------
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// PFFileUploadResult.m
3+
// Parse
4+
//
5+
// Created by Ken Cooper on 2/21/17.
6+
// Copyright © 2017 Parse Inc. All rights reserved.
7+
//
8+
9+
#import "PFFileUploadResult.h"
10+
11+
@implementation PFFileUploadResult
12+
13+
@end

Parse/Internal/Object/Subclassing/PFObjectSubclassingController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ - (void)_rawRegisterSubclass:(Class)kls {
332332

333333
- (void)_registerSubclassesInLoadedBundle:(NSBundle *)bundle {
334334
// Skip bundles that aren't loaded yet.
335-
if (!bundle.loaded || !bundle.executablePath) {
335+
if (![bundle isKindOfClass:NSBundle.class] || !bundle.loaded || !bundle.executablePath) {
336336
return;
337337
}
338338
// Filter out any system bundles

Parse/Internal/ParseClientConfiguration_Private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern NSString *const _ParseDefaultServerURLString;
1717

1818
@property (nullable, nonatomic, copy, readwrite) NSString *applicationId;
1919
@property (nullable, nonatomic, copy, readwrite) NSString *clientKey;
20+
@property (nullable, nonatomic, strong, readwrite) id<PFFileUploadController> fileUploadController;
2021

2122
@property (nonatomic, copy, readwrite) NSString *server;
2223

Parse/PFConstants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#pragma mark - SDK Version
1414
///--------------------------------------
1515

16-
#define PARSE_VERSION @"1.14.3"
16+
#define PARSE_VERSION @"1.14.4"
1717

1818
///--------------------------------------
1919
#pragma mark - Platform

Parse/PFFileUploadController.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// PFUploadController.h
3+
// Parse
4+
//
5+
// Created by Ken Cooper on 2/20/17.
6+
// Copyright © 2017 Parse Inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <Bolts/BFTask.h>
11+
12+
/**
13+
A policy interface for overriding the default upload behavior of uploading a PFFile
14+
to application's parse server. Allows for direct uploads to other file storage
15+
providers.
16+
*/
17+
@protocol PFFileUploadController <NSObject>
18+
19+
/**
20+
Uploads a file asynchronously from file path for a given file state.
21+
22+
@param sourceFilePath Path to the file to upload.
23+
@param fileName The PFFile's fileName.
24+
@param mimeType The PFFile's mime type.
25+
@param sessionToken The current users's session token.
26+
@param cancellationToken Cancellation token.
27+
@param progressBlock Progress block to call (optional).
28+
29+
@return `BFTask` with a success result set to `PFFileUploadResult` containing the url and name of the uploaded file.
30+
*/
31+
-(BFTask<PFFileUploadResult *> * _Nonnull)uploadSourceFilePath:(NSString * _Nonnull)sourceFilePath
32+
fileName:(NSString * _Nullable)fileName
33+
mimeType:(NSString * _Nullable)mimeType
34+
sessionToken:(NSString * _Nonnull)sessionToken
35+
cancellationToken:(BFCancellationToken * _Nonnull)cancellationToken
36+
progressBlock:(PFProgressBlock _Nonnull)progressBlock;
37+
@end

Parse/PFFileUploadResult.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// PFFileUploadResult.h
3+
// Parse
4+
//
5+
// Created by Ken Cooper on 2/21/17.
6+
// Copyright © 2017 Parse Inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
/**
12+
Response provided by a custom `PFFileUploadController`.
13+
*/
14+
@interface PFFileUploadResult : NSObject
15+
@property (strong, nonatomic) NSString *url;
16+
@property (strong, nonatomic) NSString *name;
17+
@end

Parse/Parse.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#import <Parse/PFUser+Synchronous.h>
4040
#import <Parse/PFUser+Deprecated.h>
4141
#import <Parse/PFUserAuthenticationDelegate.h>
42+
#import <Parse/PFFileUploadResult.h>
43+
#import <Parse/PFFileUploadController.h>
4244

4345
#if TARGET_OS_IOS
4446

Parse/ParseClientConfiguration.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#import <Parse/PFConstants.h>
1313

14+
@protocol PFFileUploadController;
15+
1416
NS_ASSUME_NONNULL_BEGIN
1517

1618
/**
@@ -49,6 +51,11 @@ NS_ASSUME_NONNULL_BEGIN
4951
*/
5052
@property (nonatomic, copy) NSString *server;
5153

54+
/**
55+
Sets a custom file upload controller that uploads PFFiles using its own policy.
56+
*/
57+
@property (nonatomic, strong, readwrite, nullable) id<PFFileUploadController> fileUploadController;
58+
5259
///--------------------------------------
5360
#pragma mark - Enabling Local Datastore
5461
///--------------------------------------
@@ -125,6 +132,11 @@ NS_ASSUME_NONNULL_BEGIN
125132
*/
126133
@property (nonatomic, copy, readonly) NSString *server;
127134

135+
/**
136+
The custom upload controller that synchronously uploads PFFiles using its own policy.
137+
*/
138+
@property (nonatomic, strong, readonly, nullable) id<PFFileUploadController> fileUploadController;
139+
128140
///--------------------------------------
129141
#pragma mark - Enabling Local Datastore
130142
///--------------------------------------

Parse/ParseClientConfiguration.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ - (BOOL)isEqual:(id)object {
112112
return ([PFObjectUtilities isObject:self.applicationId equalToObject:other.applicationId] &&
113113
[PFObjectUtilities isObject:self.clientKey equalToObject:other.clientKey] &&
114114
[self.server isEqualToString:other.server] &&
115+
self.fileUploadController == other.fileUploadController &&
115116
self.localDatastoreEnabled == other.localDatastoreEnabled &&
116117
[PFObjectUtilities isObject:self.applicationGroupIdentifier equalToObject:other.applicationGroupIdentifier] &&
117118
[PFObjectUtilities isObject:self.containingApplicationBundleIdentifier equalToObject:other.containingApplicationBundleIdentifier] &&
@@ -128,6 +129,7 @@ - (instancetype)copyWithZone:(NSZone *)zone {
128129
configuration->_applicationId = [self->_applicationId copy];
129130
configuration->_clientKey = [self->_clientKey copy];
130131
configuration->_server = [self.server copy];
132+
configuration->_fileUploadController = self->_fileUploadController;
131133
configuration->_localDatastoreEnabled = self->_localDatastoreEnabled;
132134
configuration->_applicationGroupIdentifier = [self->_applicationGroupIdentifier copy];
133135
configuration->_containingApplicationBundleIdentifier = [self->_containingApplicationBundleIdentifier copy];

Parse/Resources/Parse-OSX.Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
<key>CFBundlePackageType</key>
1414
<string>FMWK</string>
1515
<key>CFBundleShortVersionString</key>
16-
<string>1.14.2</string>
16+
<string>1.14.4</string>
1717
<key>CFBundleSignature</key>
1818
<string>????</string>
1919
<key>CFBundleVersion</key>
20-
<string>1.14.2</string>
20+
<string>1.14.4</string>
2121
</dict>
2222
</plist>

Parse/Resources/Parse-iOS.Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<key>CFBundlePackageType</key>
1414
<string>FMWK</string>
1515
<key>CFBundleShortVersionString</key>
16-
<string>1.14.2</string>
16+
<string>1.14.4</string>
1717
<key>CFBundleSignature</key>
1818
<string>????</string>
1919
<key>CFBundleSupportedPlatforms</key>
@@ -22,7 +22,7 @@
2222
<string>iPhoneOS</string>
2323
</array>
2424
<key>CFBundleVersion</key>
25-
<string>1.14.2</string>
25+
<string>1.14.4</string>
2626
<key>MinimumOSVersion</key>
2727
<string>6.0</string>
2828
</dict>

Parse/Resources/Parse-tvOS.Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.14.2</string>
18+
<string>1.14.4</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>1.14.2</string>
22+
<string>1.14.4</string>
2323
<key>NSPrincipalClass</key>
2424
<string></string>
2525
</dict>

Parse/Resources/Parse-watchOS.Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.14.2</string>
18+
<string>1.14.4</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>1.14.2</string>
22+
<string>1.14.4</string>
2323
<key>NSPrincipalClass</key>
2424
<string></string>
2525
</dict>

ParseStarterProject/OSX/ParseOSXStarterProject-Swift/Resources/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.14.2</string>
20+
<string>1.14.4</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>1.14.2</string>
24+
<string>1.14.4</string>
2525
<key>LSMinimumSystemVersion</key>
2626
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
2727
<key>NSMainNibFile</key>

ParseStarterProject/OSX/ParseOSXStarterProject/Resources/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.14.2</string>
20+
<string>1.14.4</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>1.14.2</string>
24+
<string>1.14.4</string>
2525
<key>LSMinimumSystemVersion</key>
2626
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
2727
<key>NSMainNibFile</key>

ParseStarterProject/iOS/ParseStarterProject-Swift/Resources/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.14.2</string>
18+
<string>1.14.4</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>1.14.2</string>
22+
<string>1.14.4</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UILaunchStoryboardName</key>

ParseStarterProject/iOS/ParseStarterProject/Resources/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
<key>CFBundlePackageType</key>
2020
<string>APPL</string>
2121
<key>CFBundleShortVersionString</key>
22-
<string>1.14.2</string>
22+
<string>1.14.4</string>
2323
<key>CFBundleSignature</key>
2424
<string>????</string>
2525
<key>CFBundleVersion</key>
26-
<string>1.14.2</string>
26+
<string>1.14.4</string>
2727
<key>LSRequiresIPhoneOS</key>
2828
<true/>
2929
<key>NSMainNibFile</key>

ParseStarterProject/tvOS/ParseStarterProject-Swift/ParseStarter/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.14.2</string>
18+
<string>1.14.4</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>1.14.2</string>
22+
<string>1.14.4</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIMainStoryboardFile</key>

ParseStarterProject/watchOS/ParseStarterProject-Swift/ParseStarter Extension/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>XPC!</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.14.2</string>
20+
<string>1.14.4</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>1.14.2</string>
24+
<string>1.14.4</string>
2525
<key>NSExtension</key>
2626
<dict>
2727
<key>NSExtensionAttributes</key>

0 commit comments

Comments
 (0)