diff --git a/FPPicker/Shared/FPLibrary.h b/FPPicker/Shared/FPLibrary.h index 365688d..8533788 100644 --- a/FPPicker/Shared/FPLibrary.h +++ b/FPPicker/Shared/FPLibrary.h @@ -43,6 +43,13 @@ andMimetypes:(NSArray *)mimetypes cachePolicy:(NSURLRequestCachePolicy)policy; ++ (NSURLRequest *)requestForLoadPath:(NSString *)loadpath + withFormat:(NSString *)type + queryString:(NSString *)queryString + andMimetypes:(NSArray *)mimetypes + cachePolicy:(NSURLRequestCachePolicy)policy + shouldURLEncode:(BOOL)encode; + #ifdef FPLibrary_protected + (void)uploadLocalURLToFilepicker:(NSURL *)localURL diff --git a/FPPicker/Shared/FPLibrary.m b/FPPicker/Shared/FPLibrary.m index 181e0b6..b2d5f20 100644 --- a/FPPicker/Shared/FPLibrary.m +++ b/FPPicker/Shared/FPLibrary.m @@ -25,7 +25,8 @@ + (void)requestObjectMediaInfo:(NSDictionary *)obj withFormat:@"data" queryString:nil andMimetypes:source.mimetypes - cachePolicy:NSURLRequestReloadRevalidatingCacheData]; + cachePolicy:NSURLRequestReloadRevalidatingCacheData + shouldURLEncode:NO]; NSString *tempPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[FPUtils genRandStringLength:20]]; @@ -281,6 +282,21 @@ + (NSURLRequest *)requestForLoadPath:(NSString *)loadpath queryString:(NSString *)queryString andMimetypes:(NSArray *)mimetypes cachePolicy:(NSURLRequestCachePolicy)policy +{ + return [self requestForLoadPath:loadpath + withFormat:type + queryString:queryString + andMimetypes:mimetypes + cachePolicy:policy + shouldURLEncode:YES]; +} + ++ (NSURLRequest *)requestForLoadPath:(NSString *)loadpath + withFormat:(NSString *)type + queryString:(NSString *)queryString + andMimetypes:(NSArray *)mimetypes + cachePolicy:(NSURLRequestCachePolicy)policy + shouldURLEncode:(BOOL)encode; { FPSession *fpSession = [FPSession sessionForFileUploads]; fpSession.mimetypes = mimetypes; @@ -289,7 +305,14 @@ + (NSURLRequest *)requestForLoadPath:(NSString *)loadpath NSURLComponents *urlComponents = [NSURLComponents componentsWithString:fpBASE_URL]; urlComponents.query = queryString; - urlComponents.path = [NSString stringWithFormat:@"/api/path%@", loadpath]; + if (encode) + { + urlComponents.path = [NSString stringWithFormat:@"/api/path%@", loadpath]; + } + else + { + urlComponents.percentEncodedPath = [NSString stringWithFormat:@"/api/path%@", loadpath]; + } NSArray *queryItems = @[ [NSURLQueryItem queryItemWithName:@"format" value:type],