Re: NSURL - download files
Re: NSURL - download files
- Subject: Re: NSURL - download files
- From: Stefan Pantke <email@hidden>
- Date: Fri, 13 Feb 2004 13:51:21 +0100
Is this really true?
How about
- (BOOL)writeToURL:(NSURL *)aURL atomically:(BOOL)atomically
and encoding in an FTP:// like URL username and password? Will this
really fail to write NSData to an FTP-Server?
- Stefan
Am 13.02.2004 um 13:18 schrieb m:
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.
_______________________________________________
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.