Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Upload tasks from NSData are not supported in background sessions #474

Open
littleben803 opened this issue May 26, 2016 · 0 comments
Open

Comments

@littleben803
Copy link

When I use startUploadRequest to upload image data to server, it throw a exception:
"Upload tasks from NSData are not supported in background sessions"

the code is such like that:
//------------------------------------------------------------------------------------------------------------------------------
MKNetworkRequest *request = [self.host requestWithPath:@"MyUrl" params:finalSendParams httpMethod:@"POST"];
[request attachData:data forKey:@"img" mimeType:@"image/jpeg" suggestedFileName:@"img.jpg"];
[self.host startUploadRequest:request];
//------------------------------------------------------------------------------------------------------------------------------

in function -(void) startUploadRequest:(MKNetworkRequest*) request;
use the backgroundSession like that:
request.task = [self.backgroundSession uploadTaskWithRequest:request.request
fromData:request.multipartFormData];

maybe we can only upload files "fromFile" in backgroundSession rather then "fromData".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant