Skip to content

Commit

Permalink
Merge commit 'b5c49540caf930dbaf47a9c0f07cddac6cdd9674' into release/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
tkhoa87 committed Apr 10, 2017
2 parents c99e59e + b5c4954 commit 66002bd
Show file tree
Hide file tree
Showing 27 changed files with 206 additions and 42 deletions.
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-----

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.
4 changes: 4 additions & 0 deletions PATENTS
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ necessarily infringed by the Software standing alone.
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
or contributory infringement or inducement to infringe any patent, including a
cross-claim or counterclaim.

-----

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.
2 changes: 1 addition & 1 deletion Parse.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Parse'
s.version = '1.14.3'
s.version = '1.14.4'
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.homepage = 'https://www.parse.com/'
s.summary = 'A library that gives you access to the powerful Parse cloud platform from your iOS/OS X/watchOS/tvOS app.'
Expand Down
48 changes: 48 additions & 0 deletions Parse.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

52 changes: 37 additions & 15 deletions Parse/Internal/File/Controller/PFFileController.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#import "PFMacros.h"
#import "PFRESTFileCommand.h"
#import "PFErrorUtilities.h"
#import "Parse.h"
#import "PFFileUploadController.h"

static NSString *const PFFileControllerCacheDirectoryName_ = @"PFFileCache";

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

PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name sessionToken:sessionToken];
@weakify(self);
return [[self.dataSource.commandRunner runFileUploadCommandAsync:command
withContentType:fileState.mimeType
contentSourceFilePath:sourceFilePath
options:PFCommandRunningOptionRetryIfFailed
cancellationToken:cancellationToken
progressBlock:progressBlock] continueWithSuccessBlock:^id(BFTask<PFCommandResult *> *task) {
@strongify(self);
PFCommandResult *result = task.result;
PFFileState *fileState = [[PFFileState alloc] initWithName:result.result[@"name"]
urlString:result.result[@"url"]
mimeType:nil];
return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState];
}];

id<PFFileUploadController> customFileUploadController = Parse.currentConfiguration.fileUploadController;
if (customFileUploadController) {
@weakify(self);
return [[customFileUploadController uploadSourceFilePath:sourceFilePath
fileName:fileState.name
mimeType:fileState.mimeType
sessionToken:sessionToken
cancellationToken:cancellationToken
progressBlock:progressBlock]
continueWithSuccessBlock:^id(BFTask<PFFileUploadResult *> *task) {
@strongify(self);
PFFileUploadResult *result = task.result;
PFFileState *fileState = [[PFFileState alloc] initWithName:result.name
urlString:result.url
mimeType:nil];
return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState];
}];
} else {
PFRESTFileCommand *command = [PFRESTFileCommand uploadCommandForFileWithName:fileState.name sessionToken:sessionToken];
@weakify(self);
return [[self.dataSource.commandRunner runFileUploadCommandAsync:command
withContentType:fileState.mimeType
contentSourceFilePath:sourceFilePath
options:PFCommandRunningOptionRetryIfFailed
cancellationToken:cancellationToken
progressBlock:progressBlock] continueWithSuccessBlock:^id(BFTask<PFCommandResult *> *task) {
@strongify(self);
PFCommandResult *result = task.result;
PFFileState *fileState = [[PFFileState alloc] initWithName:result.result[@"name"]
urlString:result.result[@"url"]
mimeType:nil];
return [[self _cacheFileAsyncWithState:fileState atPath:sourceFilePath] continueWithSuccessResult:fileState];
}];
}
}

///--------------------------------------
Expand Down
13 changes: 13 additions & 0 deletions Parse/Internal/File/Controller/PFFileUploadResult.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// PFFileUploadResult.m
// Parse
//
// Created by Ken Cooper on 2/21/17.
// Copyright © 2017 Parse Inc. All rights reserved.
//

#import "PFFileUploadResult.h"

@implementation PFFileUploadResult

@end
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ - (void)_rawRegisterSubclass:(Class)kls {

- (void)_registerSubclassesInLoadedBundle:(NSBundle *)bundle {
// Skip bundles that aren't loaded yet.
if (!bundle.loaded || !bundle.executablePath) {
if (![bundle isKindOfClass:NSBundle.class] || !bundle.loaded || !bundle.executablePath) {
return;
}
// Filter out any system bundles
Expand Down
1 change: 1 addition & 0 deletions Parse/Internal/ParseClientConfiguration_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern NSString *const _ParseDefaultServerURLString;

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

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

Expand Down
2 changes: 1 addition & 1 deletion Parse/PFConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#pragma mark - SDK Version
///--------------------------------------

#define PARSE_VERSION @"1.14.3"
#define PARSE_VERSION @"1.14.4"

///--------------------------------------
#pragma mark - Platform
Expand Down
37 changes: 37 additions & 0 deletions Parse/PFFileUploadController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// PFUploadController.h
// Parse
//
// Created by Ken Cooper on 2/20/17.
// Copyright © 2017 Parse Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Bolts/BFTask.h>

/**
A policy interface for overriding the default upload behavior of uploading a PFFile
to application's parse server. Allows for direct uploads to other file storage
providers.
*/
@protocol PFFileUploadController <NSObject>

/**
Uploads a file asynchronously from file path for a given file state.
@param sourceFilePath Path to the file to upload.
@param fileName The PFFile's fileName.
@param mimeType The PFFile's mime type.
@param sessionToken The current users's session token.
@param cancellationToken Cancellation token.
@param progressBlock Progress block to call (optional).
@return `BFTask` with a success result set to `PFFileUploadResult` containing the url and name of the uploaded file.
*/
-(BFTask<PFFileUploadResult *> * _Nonnull)uploadSourceFilePath:(NSString * _Nonnull)sourceFilePath
fileName:(NSString * _Nullable)fileName
mimeType:(NSString * _Nullable)mimeType
sessionToken:(NSString * _Nonnull)sessionToken
cancellationToken:(BFCancellationToken * _Nonnull)cancellationToken
progressBlock:(PFProgressBlock _Nonnull)progressBlock;
@end
17 changes: 17 additions & 0 deletions Parse/PFFileUploadResult.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// PFFileUploadResult.h
// Parse
//
// Created by Ken Cooper on 2/21/17.
// Copyright © 2017 Parse Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
Response provided by a custom `PFFileUploadController`.
*/
@interface PFFileUploadResult : NSObject
@property (strong, nonatomic) NSString *url;
@property (strong, nonatomic) NSString *name;
@end
2 changes: 2 additions & 0 deletions Parse/Parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#import <Parse/PFUser+Synchronous.h>
#import <Parse/PFUser+Deprecated.h>
#import <Parse/PFUserAuthenticationDelegate.h>
#import <Parse/PFFileUploadResult.h>
#import <Parse/PFFileUploadController.h>

#if TARGET_OS_IOS

Expand Down
12 changes: 12 additions & 0 deletions Parse/ParseClientConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#import <Parse/PFConstants.h>

@protocol PFFileUploadController;

NS_ASSUME_NONNULL_BEGIN

/**
Expand Down Expand Up @@ -49,6 +51,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, copy) NSString *server;

/**
Sets a custom file upload controller that uploads PFFiles using its own policy.
*/
@property (nonatomic, strong, readwrite, nullable) id<PFFileUploadController> fileUploadController;

///--------------------------------------
#pragma mark - Enabling Local Datastore
///--------------------------------------
Expand Down Expand Up @@ -125,6 +132,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, copy, readonly) NSString *server;

/**
The custom upload controller that synchronously uploads PFFiles using its own policy.
*/
@property (nonatomic, strong, readonly, nullable) id<PFFileUploadController> fileUploadController;

///--------------------------------------
#pragma mark - Enabling Local Datastore
///--------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions Parse/ParseClientConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ - (BOOL)isEqual:(id)object {
return ([PFObjectUtilities isObject:self.applicationId equalToObject:other.applicationId] &&
[PFObjectUtilities isObject:self.clientKey equalToObject:other.clientKey] &&
[self.server isEqualToString:other.server] &&
self.fileUploadController == other.fileUploadController &&
self.localDatastoreEnabled == other.localDatastoreEnabled &&
[PFObjectUtilities isObject:self.applicationGroupIdentifier equalToObject:other.applicationGroupIdentifier] &&
[PFObjectUtilities isObject:self.containingApplicationBundleIdentifier equalToObject:other.containingApplicationBundleIdentifier] &&
Expand All @@ -128,6 +129,7 @@ - (instancetype)copyWithZone:(NSZone *)zone {
configuration->_applicationId = [self->_applicationId copy];
configuration->_clientKey = [self->_clientKey copy];
configuration->_server = [self.server copy];
configuration->_fileUploadController = self->_fileUploadController;
configuration->_localDatastoreEnabled = self->_localDatastoreEnabled;
configuration->_applicationGroupIdentifier = [self->_applicationGroupIdentifier copy];
configuration->_containingApplicationBundleIdentifier = [self->_containingApplicationBundleIdentifier copy];
Expand Down
4 changes: 2 additions & 2 deletions Parse/Resources/Parse-OSX.Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions Parse/Resources/Parse-iOS.Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
Expand All @@ -22,7 +22,7 @@
<string>iPhoneOS</string>
</array>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>MinimumOSVersion</key>
<string>6.0</string>
</dict>
Expand Down
4 changes: 2 additions & 2 deletions Parse/Resources/Parse-tvOS.Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
4 changes: 2 additions & 2 deletions Parse/Resources/Parse-watchOS.Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSMainNibFile</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.14.2</string>
<string>1.14.4</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
Loading

0 comments on commit 66002bd

Please sign in to comment.