• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURL - download files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURL - download files


  • Subject: Re: NSURL - download files
  • From: m <email@hidden>
  • Date: Fri, 13 Feb 2004 04:18:59 -0800

On Feb 13, 2004, at 2:31 AM, Ramakrishna Kondapalli wrote:

I want to send/receive files from my application (Cocoa - ObjC
application) to another mac machine in my network. How to use NSURL in
this regard? How to do the login/password authentication

Frustratingly, non of NSURL-ish classes allows uploading of files. You're better off using the CURLHandle framework <http://curlhandle.sourceforge.net/>.

Search the usual places for more wisdom on CURLHandle. It's out there...

<http://cocoadevcentral.com/>
<http://www.cocoadev.com/index.pl?FindPage&value=CocoaDev>


Meanwhile to get you started, here's an example of how to upload a file using CURLHandle:

+ (NSString*)uploadOneFile: (NSString*)inFilePath // e.g. @"/User/me/somefile.txt"
toHost: (NSString*)inHost // e.g. @"ftp.somehost.net"
withUserName: (NSString*)inUserName // e.g. @"myUserName"
andPassword: (NSString*)inPassword // e.g. @"myPassword"
andDirectoryOnHost: (NSString*)inDirectoryOnHost // e.g. @"/remotedir1/remotedir2"
{
NSString* urlString = [NSString stringWithFormat: @"ftp://%@:%@@%@/%@/%@";,
inUserName,
inPassword,
inHost,
inDirectoryOnHost,
[inFilePath lastPathComponent]];

NSURL* url = [NSURL URLWithString:urlString];
CURLHandle* urlHandle = (CURLHandle *)[url URLHandleUsingCache:NO];

[urlHandle setPutFile:inFilePath];
[urlHandle prepareAndPerformCurl];

NSString* errorString = [urlHandle curlError];
if ([errorString length] == 0)
{
errorString = nil;
}
return errorString;
}


Regards,

_murat
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSURL - download files
      • From: Stefan Pantke <email@hidden>
References: 
 >NSURL - download files (From: "Ramakrishna Kondapalli" <email@hidden>)

  • Prev by Date: Re: static objects "autoreleased with no pool in place - just leaking"
  • Next by Date: Re: How to set up manual bindings
  • Previous by thread: NSURL - download files
  • Next by thread: Re: NSURL - download files
  • Index(es):
    • Date
    • Thread