<div dir="ltr">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.<div><br></div><div>Here what i'm doing.</div><div><br></div><div>1) Get a user photo from camera ou library</div><div>2) Issue a save request to the api endpoint.</div><div><br></div><div>The problem i'm having is that i get the following error:</div><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo"><b>The operation couldn’t be completed. (NSURLErrorDomain error -1001.)" UserInfo=0x79f01e00 {NSErrorFailingURLKey=http://<Server IP>/service/test/uploadios, NSErrorFailingURLStringKey=http://</b><b>http://<Server IP>/service/test/uploadios</b><b>, NSUnderlyingError=0x79fd9020 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1001.</b></p><p style="margin:0px;font-size:11px;font-family:Menlo"><b><br></b></p></div><div>Below is the code i'm using from this: </div><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo">-(<span style="color:rgb(187,44,162)">void</span>)performPhotoUpload</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">{</p></div><div><p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(61,29,129)"><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(112,61,170)">NSString</span><span style="color:rgb(0,0,0)"> *webservicePref = [[</span><span style="color:rgb(112,61,170)">NSUserDefaults</span><span style="color:rgb(0,0,0)"> </span>standardUserDefaults<span style="color:rgb(0,0,0)">] </span>stringForKey<span style="color:rgb(0,0,0)">:</span><span style="color:rgb(209,47,27)">@"serviceUrlSetting"</span><span style="color:rgb(0,0,0)">];</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(112,61,170)">NSURL</span> *projectsURL = [<span style="color:rgb(112,61,170)">NSURL</span> <span style="color:rgb(61,29,129)">URLWithString</span>:webservicePref];</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(187,44,162)">id</span><<span style="color:rgb(79,129,135)">AGPipe</span>> registrationPipe;</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(79,129,135)">AGPipeline</span> *pipeline = [<span style="color:rgb(79,129,135)">AGPipeline</span> <span style="color:rgb(49,89,93)">pipelineWithBaseURL</span>:projectsURL];</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> registrationPipe = [pipeline <span style="color:rgb(49,89,93)">pipe</span>:^(<span style="color:rgb(187,44,162)">id</span><<span style="color:rgb(79,129,135)">AGPipeConfig</span>> config) {</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(209,47,27)"><span style="color:rgb(0,0,0)"> [config </span><span style="color:rgb(49,89,93)">setName</span><span style="color:rgb(0,0,0)">:</span>@"/service/test/uploadios"<span style="color:rgb(0,0,0)">];</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> [config <span style="color:rgb(49,89,93)">setType</span>:<span style="color:rgb(209,47,27)">@"REST"</span>];</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> }];</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> [registrationPipe <span style="color:rgb(49,89,93)">save</span>:[<span style="color:rgb(187,44,162)">self</span> <span style="color:rgb(49,89,93)">extractMultiPartData</span>]</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(49,89,93)">success</span>:^(<span style="color:rgb(187,44,162)">id</span> responseObject)</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> {</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(61,29,129)">NSLog</span>(<span style="color:rgb(209,47,27)">@"Returned Object:%@"</span>, responseObject);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"> </span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> }</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(49,89,93)">failure</span>:^(<span style="color:rgb(112,61,170)">NSError</span> *error)</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> {</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(209,47,27)"><span style="color:rgb(0,0,0)"> </span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(61,29,129)">NSLog</span>(<span style="color:rgb(209,47,27)">@"Error:%@"</span>,[error <span style="color:rgb(61,29,129)">description</span>]);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> }];</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo">-(<span style="color:rgb(112,61,170)">NSDictionary</span> *)extractMultiPartData</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">{</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(112,61,170)"><span style="color:rgb(0,0,0)"> </span>NSString<span style="color:rgb(0,0,0)"> *filename = </span><span style="color:rgb(187,44,162)">self</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(79,129,135)">patientPhoto</span><span style="color:rgb(0,0,0)">.</span>accessibilityIdentifier<span style="color:rgb(0,0,0)">;</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"> </span>//Check if an image was assigned for user</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> [<span style="color:rgb(187,44,162)">self</span> <span style="color:rgb(49,89,93)">hasPhoto</span>:filename];</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(112,61,170)">NSData</span> *imageData = <span style="color:rgb(61,29,129)">UIImageJPEGRepresentation</span>(<span style="color:rgb(187,44,162)">self</span>.<span style="color:rgb(79,129,135)">patientPhoto</span>.<span style="color:rgb(112,61,170)">image</span>, <span style="color:rgb(39,42,216)">0.2</span>);</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(79,129,135)">AGFileDataPart</span> *dataPart = [[<span style="color:rgb(79,129,135)">AGFileDataPart</span> <span style="color:rgb(61,29,129)">alloc</span>] <span style="color:rgb(49,89,93)">initWithFileData</span>:imageData <span style="color:rgb(49,89,93)">name</span>: <span style="color:rgb(209,47,27)">@"image"</span></p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(49,89,93)">fileName</span>:filename</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(49,89,93)">mimeType</span>:<span style="color:rgb(209,47,27)">@"application/octet-stream"</span>];</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(112,61,170)">NSDictionary</span> *imgDict = <span style="color:rgb(39,42,216)">@{</span><span style="color:rgb(209,47,27)">@"data"</span>: dataPart<span style="color:rgb(39,42,216)">}</span>;</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"> </p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:rgb(187,44,162)">return</span> imgDict;</p></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div>Desenvolvedor IOS, Rails, RIA</div><div><br></div><div><a href="http://www.linkedin.com/in/marcpires" target="_blank">http://www.linkedin.com/in/marcpires</a><br></div><a href="http://about.me/marcelo_pires" target="_blank">http://about.me/marcelo_pires</a><br></div></div>
</div></div>