Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-22-2009, 09:45 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 5
Default FTP upload of multiple files

Hi all,
I am a beginner iPhone developer and I'm writing an app to upload a set of local files to an FTP server.

I started from the SimpleFTPSample application, then I modified it in order to upload N files in a row, but only one file is uploaded.

I also implemented the solution described in the "Working with FTP Server" page (with the callback and all) but I got the same behaviour.

These are my steps (for each file).

Code:
// Open the file stream ('t' is a structure containing the fileName and read/write streams)
CFURLRef fileNameURL = CFURLCreateWithFileSystemPath(NULL, (CFStringRef)t.fileName, kCFURLPOSIXPathStyle, FALSE);
t.readStream = CFReadStreamCreateWithFile(NULL, fileNameURL);
CFReadStreamOpen(t.readStream);
CFStreamStatus streamStatus = CFReadStreamGetStatus(t.readStream);
assert(streamStatus == kCFStreamStatusOpening || streamStatus == kCFStreamStatusOpen);

// Create the FTP stream
t.writeStream = CFWriteStreamCreateWithFTPURL(NULL, (CFURLRef)t.ftpURL);

// Register the callback
context.info = t;
CFWriteStreamSetClient(t.writeStream, kCFStreamEventCanAcceptBytes|kCFStreamEventErrorOccurred|FStreamEventEndEncountered, CFWriteStreamClientCallBack)&writeStreamCallback, &context);

// 'writeStreamCallback' reads chunks of bytes from readStream and writes them to writeStream

// Schedule in RunLoop
[(NSStream*)t.writeStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
	
// Open the FTP stream (this should start the transfer)
CFWriteStreamOpen(t.writeStream);
stramStatus = CFWriteStreamGetStatus(t.writeStream);
assert(streamStatus == kCFStreamStatusOpening || streamStatus == kCFStreamStatusOpen);
The callback function is not called immediately after I open the FTP stream, but after a while (possibly it starts at the beginning of the following RunLoop, but just guessing…).
If I schedule more writeStreams in RunLoop, only the first one is executed.

I also tried to spin a new thread for each file to be uploaded (since, from my understanding, each NSThread has its own RunLoop) but it didn't work.

Could you please give me any hints?

Thank you,
Rippel

Last edited by rippeltippel; 10-22-2009 at 11:19 AM.
rippeltippel is offline   Reply With Quote
Old 10-23-2009, 10:21 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 5
Default

Problem found: the R/W streams were not closed properly.
Sorry for hassling
rippeltippel is offline   Reply With Quote
Old 07-18-2011, 04:12 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 93
Default

Hi,
I'm noob to upload ftp file.
I look your code but I dont I can't create the stream file
Do you help me?
Thanks
freedoom is offline   Reply With Quote
Old 07-18-2011, 04:18 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 93
Default

Hi,
I'm noob to upload ftp file.
I look your code but I dont I can't create the stream file
Do you help me?
Thanks
freedoom is offline   Reply With Quote
Reply

Bookmarks

Tags
ftp, multiple files, upload

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 267
19 members and 248 guests
2WeeksToGo, @sandris, AdamL, ADY, Dani77, diyora, F_Bryant, GHuebner, HDshot, headkaze, mer10, Oral B, prchn4christ, Rudy, smithdale87, Thompson22, timle8n1, Touchmint, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,880
Threads: 89,228
Posts: 380,748
Top Poster: BrianSlick (7,129)
Welcome to our newest member, @sandris
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0