@@ -150,6 +150,7 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
150
150
NSString *uploadType = options[@" type" ] ?: @" raw" ;
151
151
NSString *fieldName = options[@" field" ];
152
152
NSString *customUploadId = options[@" customUploadId" ];
153
+ NSString *appGroup = options[@" appGroup" ];
153
154
NSDictionary *headers = options[@" headers" ];
154
155
NSDictionary *parameters = options[@" parameters" ];
155
156
@@ -158,7 +159,7 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
158
159
if (requestUrl == nil ) {
159
160
return reject (@" RN Uploader" , @" URL not compliant with RFC 2396" , nil );
160
161
}
161
-
162
+
162
163
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: requestUrl];
163
164
[request setHTTPMethod: method];
164
165
@@ -197,14 +198,14 @@ - (void)copyAssetToFile: (NSString *)assetUrl completionHandler: (void(^)(NSStri
197
198
NSData *httpBody = [self createBodyWithBoundary: uuidStr path: fileURI parameters: parameters fieldName: fieldName];
198
199
[request setHTTPBody: httpBody];
199
200
200
- uploadTask = [[self urlSession ] uploadTaskWithStreamedRequest: request];
201
+ uploadTask = [[self urlSession: appGroup ] uploadTaskWithStreamedRequest: request];
201
202
} else {
202
203
if (parameters.count > 0 ) {
203
204
reject (@" RN Uploader" , @" Parameters supported only in multipart type" , nil );
204
205
return ;
205
206
}
206
207
207
- uploadTask = [[self urlSession ] uploadTaskWithRequest: request fromFile: [NSURL URLWithString: fileURI]];
208
+ uploadTask = [[self urlSession: appGroup ] uploadTaskWithRequest: request fromFile: [NSURL URLWithString: fileURI]];
208
209
}
209
210
210
211
uploadTask.taskDescription = customUploadId ? customUploadId : [NSString stringWithFormat: @" %i " , thisUploadId];
@@ -266,9 +267,12 @@ - (NSData *)createBodyWithBoundary:(NSString *)boundary
266
267
return httpBody;
267
268
}
268
269
269
- - (NSURLSession *)urlSession {
270
+ - (NSURLSession *)urlSession : ( NSString *) groupId {
270
271
if (_urlSession == nil ) {
271
272
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier: BACKGROUND_SESSION_ID];
273
+ if (groupId != nil && ![groupId isEqualToString: @" " ]) {
274
+ sessionConfiguration.sharedContainerIdentifier = groupId;
275
+ }
272
276
_urlSession = [NSURLSession sessionWithConfiguration: sessionConfiguration delegate: self delegateQueue: nil ];
273
277
}
274
278
0 commit comments