Creating folder on ftp if does not exist - iphone

I am interested to find out how to perform FTP asynchronously..
I am calling one method from the main view and then the main view navigates to some other view. Now the method that is called should perform the ftp process in the background without any issue.
I am not able to achieve this: http://www.iphonedevsdk.com/forum/iphone-sdk-development/41143-beginnersquestion-simpleftp-example.html
http://developer.apple.com/library/ios/#samplecode/SimpleFTPSample/Listings/URLGetController_h.html#//apple_ref/doc/uid/DTS40009243-URLGetController_h-DontLinkElementID_15
I have referenced this but is there any other way to do the FTP process?
I have files in a queue which are ftp one after the other in the async method.

I am sorry i am able to assist with your code but i can help with the ftp command side of things, if would recommend to try and changing into the directory that you are looking for with using CWD <\dirname> and look for the response: 550 <\dirname>: No such file or directory.
When you have recieved this response you will then be able to create the directory with using the command of MKD <\dirname> to create a directory.
Hope this helps ..

Related

TFS 2013 build - uploading build output to servier via FTP

I'm hoping someone can help. I've started using the Community TFS Build Extensions, in particular the FTP activity. I followed the documentation here and got to grips with the it pretty easily. I'm encountering one major problem though.
My Web app has a basic enough structure:
I start by creating the FindMatchingFile activity which places the files in the drop location into an IEnumberable variable called FilesToFTP :
String.Format("{0}\**\*.*", BuildDetail.DropLocation)
When I iterate through the variable and print out the results, all seems correct:
G:\builds\Build.1203\CredentialManagement\bin\BusLogic.dll
G:\builds\Build.1203\CredentialManagement\css\style.css
G:\builds\Build.1203\CredentialManagement\AppError.aspx
......
G:\builds\Build.1203\CredentialManagement\Web.config
etc etc.
The problem is, when I pass that IEnumerable to the Ftp activity (converting it to a string array), it FTP uploads all the files on the server however it doesn't keep the directory structure of my Web app. It just piles all the output (dlls, aspx etc) into one directory. See the following two screenshots.
Is there any way I can use the FTP activity to upload all the output from the drop location recursively? I feel like I'm doing something simple wrong.
The FTP activity in TFS Build Extensions doesn't upload files recursively.
I think it would be a good value addition to the activity. Please create a request for the project and we will add in it. For now, you can go around it by calling the Ftp activity recursively for each directory and setting the RemoteDirectory for each.

Identify the upload status

I am uploading the folder from local to FTP using perl Net::FTP::Recursive module. I have written the sample code below. In that code I need to know the status of the uploading process like whether it has been uploaded or not.
use strict;
use Net::FTP:recursive;
my $ftp_con= Net::FTP::Recursive->new('host.com',Debug=>0);
$ftp_con->login('username','password');
$ftp_con->rput('d:\my_test','\root\my_test');
$ftp_con->quit;
In the above code I am unable to find the status of the uploading. Can anyone suggest me to get the uploading status of the folder, whether the folder has been uploaded or not.
Thanks...
Subclass Net::FTP::Recursive to override _rput. Add a callback hook to the end of the foreach block and pass in the current file $file and the list of files #files as arguments.
In the main part of the code, count up each time the callback is called and calculating the progress from the counter and the number of elements in #files.
First thing did you remember what is your folder name that you transfer via ftf. If the transfering is so fast and you are unable to monitor wether it is already in the server, you can use anothet method to verify it wether it is successfully loaded.
1. Log in to CPanel of your website via your hosting provider
2. Locate legacy file manager folder then click
3. Choose document root for, the click Go, then start to see find your folder name that you tranfer via ftp.

download multiple files using SimpleFTPSample

I've been trying to figure out how to download multiple files in a row based on the SimpleFTPSample provided by apple. Basically, I'm filtering what the user can see when they browse an ftp server, but when they select a certain file type, I want it to automatically check for another file of the same name with a different extension and if it exists, download it as well. I can't seem to get this second file to download no matter what I do. It seems strange because if I select two files in a row in my tableview, it downloads both of them just fine. Any ideas?
Edit:
It's just the SimpleFTPSample from apple.developer.com, all I did was create additional NSInputStream and NSOutputStream objects and I created a new _startReceiveFile method that gets called from _startReceive if I'm downloading a file instead of getting a directory listing. _startReceiveFile is the same code for _startReceive in the file download code for the sample project, except if the file to download has a certain extension, it also downloads an additional file with the additional stream objects. Let me know if I need to clarify more or try to put together a clear example.
Well, since there were no takers, I'll just post my solution here. I've abandoned trying to download two files at once. Instead, I just keep the ftp browsing window open and only handle the opening of the file once both files have been downloaded (user has clicked on each one separately). It's not what I wanted, but it will work, at least until I can figure out how to get two files with one request.

How to detect FTP file transfer completion?

I am writing a script that polls an FTP site for files and downloads them locally as and when available. The files are deposited to the FTP site randomly by various source parties. I need a way to be able to detect if the file on the FTP site has been transferred over completely by the source party, before downloading them. Any thoughts on how to go about this?
If you have control over the client, a much safer, cleaner and efficient way is to have the client do the following:
Upload the file to ..../partial/somefile
Rename ..../partial/somefile to ..../complete/somefile
This causes the file to appear in the latter directory all at once, so all you have to do is scan that directory. You could even ask the OS to be notified of additions to that directory if you wanted a non-polling solution.
If you cannot manipulate the FTP server itself the only way of checking that comes to my mind is polling the filesize and if the filesize doesn't change for a longer time you can be quite sure the upload has finished. But nobody can guarantee. Ideally you can adapt the FTP server and make it execute some script after finishing some upload.
Some pseudo-code:
my %filesizes;
my %processed;
sub poll {
foreach (#files_on_ftp) {
if($_->filesize == $filesizes{$_->filename} and not $processed{$_->filename}) {
process($_);
$processed{$_->filename)++;
}
}
}
Like ikegami's solution depends mine of client side:
first is file uploaded
if it is completed, client uploads empty flag-file (like file.name.txt.finished)
When you see finished-file, you know file is ready.

Uploading and downloading via ftp with iPhone SDK

Could anybody explain to me the process of uploading to and downloading form and ftp server with the iPhone SDK. If you could just point me in the right direction (e.g. documentation etc.). How difficult is a task like this?
Thanks in advance.
You can use this. It support all the basic ftp operations:
Download file
Upload file
Delete file
Delete directory
Create directory
List directory contents
[DISCLAIMER] I am the developer of the library, I needed a ftp library too in the past and came over this answer. However, I decided to write one myself because s7ftprequest didn't support at that point several operations that I needed.(like download or list directory)
Try this Simple FTP Download
The Apple documentation will provide far more info in general than I could. Have a look at:
http://developer.apple.com/iphone/library/documentation/Networking/Conceptual/CFNetwork/CFFTPTasks/CFFTPTasks.html#//apple_ref/doc/uid/TP30001132-CH9-SW1
which details the FTP information you need. If you prefer a PDF with all the networking info in it, have a look at:
http://developer.apple.com/iphone/library/documentation/Networking/Conceptual/CFNetwork/CFNetwork.pdf
In this, you'll be particularly interested in Chapter 5. Both detail working with FTP sites, including uploading, downloading, retrieving directory listings, etc.
s7ftprequest only for uploading files to FTP.
The below is sample code from apple
http://developer.apple.com/library/ios/#samplecode/SimpleFTPSample/Introduction/Intro.html
Limitations:
FTPS (that is, FTP over TLS)
deleting items
renaming items
other less common FTP commands
custom FTP commands
I ended up using GoldRacoon. It turns out that in iOS/objc land, there's BlackRaccoon as the original FTP client lib, then WhiteRaccoon was forked from that, and then GoldRacoon was forked from WhiteRaccoon (I think)
pod search GoldRaccoon
... will show you.
I ended up making a few changes (in my own fork) so that you can pass in a successBlock & failBlock into any request, so that block-y callers (like my classes) don't have extra work to manage the delegate callbacks. Github link (my fork): https://github.com/xaphod/GoldRaccoon