<div dir="ltr">Hi Guys, well, i&#39;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&#39;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&#39;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.)&quot; UserInfo=0x79f01e00 {NSErrorFailingURLKey=http://&lt;Server IP&gt;/service/test/uploadios, NSErrorFailingURLStringKey=http://</b><b>http://&lt;Server IP&gt;/service/test/uploadios</b><b>, NSUnderlyingError=0x79fd9020 &quot;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&#39;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)">@&quot;serviceUrlSetting&quot;</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>&lt;<span style="color:rgb(79,129,135)">AGPipe</span>&gt; 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>&lt;<span style="color:rgb(79,129,135)">AGPipeConfig</span>&gt; 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>@&quot;/service/test/uploadios&quot;<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)">@&quot;REST&quot;</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)">@&quot;Returned Object:%@&quot;</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)">@&quot;Error:%@&quot;</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)">@&quot;image&quot;</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)">@&quot;application/octet-stream&quot;</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)">@&quot;data&quot;</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>