Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 10, 2013, 09:51 AM   #1
mycompuser
macrumors member
 
Join Date: May 2012
File upload using curl.

Hi All,

One of the requirements of my cocoa app on Lion (using xcode) is to upload an file to an upload server as a "multipart/form-data" using HTTP POST.

I achieve the upload using NSURLConnections when I am connected via ethernet.
For some reason When I am connected via WiFi, the upload using NSURLConnection seems to fail (with an error 504).
But when I try to upload the same file to the same URL using CURL the same succeeds.
Not sure why this behavior is exhibited.

I use the following curl command
Code:
curl --form file=@/Volumes/Untitled/fig1.png http://xxxx.com/upload
I also get the response "Received 202946 bytes of file fig1.png" indicating that the upload was successful.
Note: the url specified in the sample above is dummy.

Now I am trying to implement the http upload using CURL programatically.

I've tried using the sample provided in http://curl.haxx.se/mail/lib-2008-01/0322.html but unable to succeed in uploading.
Also tried my hands on CurlHandle library but still no success.

I might be missing something very silly.

It might be too much to ask in a forum, but is it possible for some of you gurus to actually post an curl code which you know for sure does http post upload without giving any error.

Thanks & Regards.
mycompuser is offline   0 Reply With Quote
Old Jan 10, 2013, 10:58 AM   #2
KoolStar
macrumors Demi-God
 
KoolStar's Avatar
 
Join Date: Oct 2006
Location: Kentucky
Send a message via AIM to KoolStar Send a message via Skype™ to KoolStar
Have you tried looking at a networking framework such as MKNetworkKit or ASINetwork to handle the uploading for you?
__________________
"Innovation distinguishes between a leader and a follower." : S.J.
KoolStar is offline   0 Reply With Quote
Old Jan 10, 2013, 04:24 PM   #3
larswik
macrumors 65816
 
Join Date: Sep 2006
I asked about something similar in a few posts below. I could not get the ASINetwork stuff working? Downloading from the web is an easy task but uploading is a major pain. My code logs in successfully and then just hangs and does nothing?

I am curious if you figure this out.
__________________
I know more than yesterday.
Lars
larswik is offline   0 Reply With Quote
Old Jan 13, 2013, 12:57 PM   #4
mycompuser
Thread Starter
macrumors member
 
Join Date: May 2012
Hi KoolStar,

Thanks for the reply. Sorry for the delay to respond.

I am not familiar with either of these networking framework.

I managed to get the upload using Curlhandle working. Not sure why it was not working earlier.

Have uploaded the test app which perform an HTTP POST and GET using CURLHandle.

Hi larswik,

Hope this test app helps you with the upload.

Note: In the uploaded project, pls replace the place holders for upload and download URL strings with valid values.
Attached Files
File Type: zip TestApp.zip (92.3 KB, 82 views)

Last edited by mycompuser; Jan 13, 2013 at 01:04 PM.
mycompuser is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How Can I Rename/Delete a File While In The "Select File To Upload" Window? JJ2Man OS X 10.8 Mountain Lion 1 Aug 6, 2013 06:38 AM
Upload any kind of file (pdf, jpg, etc) to iTunes Match arubinst iCloud and Apple Services 1 Jan 9, 2013 09:24 AM
How do I upload an excel file to a post? Apple fanboy Site and Forum Feedback 4 Oct 28, 2012 06:54 PM
Any tweak to upload file from iPad ipos Jailbreaks and iOS Hacks 0 Jun 4, 2012 02:11 AM

Forum Jump

All times are GMT -5. The time now is 01:23 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC