[aerogear-dev] File Upload

Christos Vasilakis cvasilak at gmail.com
Tue Nov 18 11:13:40 EST 2014


Hi Marc,

are you testing on the device or an emulator. Digging the error message the code  -1001 implies "Request Time out”

Mind to try using curl directly to perform a multipart and if it success check on the emulator. If it works guess there is some connectivity issue 

Let us know your findings

Thanks!
Christos


[1] http://stackoverflow.com/questions/19116016/what-is-the-right-way-to-post-multipart-form-data-using-curl


On Nov 18, 2014, at 3:26 PM, Marc Pires <marcpiresrj at gmail.com> wrote:

> Hi Guys, well, i'm developing an app that uses the 1.6 version  of AeroGear. Everything is going very with except that i could not get an image (from a UIImageView) upload to work.
> 
> Here what i'm doing.
> 
> 1) Get a user photo from camera ou library
> 2) Issue a save request to the api endpoint.
> 
> The problem i'm having is that i get the following error:
> 
> The operation couldn’t be completed. (NSURLErrorDomain error -1001.)" UserInfo=0x79f01e00 {NSErrorFailingURLKey=http://<Server IP>/service/test/uploadios, NSErrorFailingURLStringKey=http://http://<Server IP>/service/test/uploadios, NSUnderlyingError=0x79fd9020 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1001.
> 
> Below is the code i'm using from this: 
> 
> -(void)performPhotoUpload
> {
>    NSString *webservicePref = [[NSUserDefaults standardUserDefaults] stringForKey:@"serviceUrlSetting"];
>     
>     NSURL *projectsURL = [NSURL URLWithString:webservicePref];
>     
>     id<AGPipe> registrationPipe;
>     
>     AGPipeline *pipeline = [AGPipeline pipelineWithBaseURL:projectsURL];
>     
>     registrationPipe = [pipeline pipe:^(id<AGPipeConfig> config) {
>         
>         [config setName:@"/service/test/uploadios"];
>         [config setType:@"REST"];
>         
>     }];
>     
>     
>     [registrationPipe save:[self extractMultiPartData]
>                    success:^(id responseObject)
>      {
>          NSLog(@"Returned Object:%@", responseObject);
>       
>      }
>      failure:^(NSError *error)
>      {
>          
>          NSLog(@"Error:%@",[error description]);
>          
>      }];
>     
> 
> -(NSDictionary *)extractMultiPartData
> {
>     NSString *filename = self.patientPhoto.accessibilityIdentifier;
>     
>     //Check if an image was assigned for user
>     [self hasPhoto:filename];
>     
>     NSData *imageData = UIImageJPEGRepresentation(self.patientPhoto.image, 0.2);
>     
>     AGFileDataPart *dataPart = [[AGFileDataPart alloc] initWithFileData:imageData                                                                 name: @"image"
>                                                                    fileName:filename
>                                                                    mimeType:@"application/octet-stream"];
>     
>     
>     NSDictionary *imgDict = @{@"data": dataPart};
>     
>     return imgDict;
> 
> -- 
> Desenvolvedor IOS, Rails, RIA
> 
> http://www.linkedin.com/in/marcpires
> http://about.me/marcelo_pires
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20141118/33652ca1/attachment-0001.html 


More information about the aerogear-dev mailing list