GithubHelp home page GithubHelp logo

albertodebortoli / goldraccoon Goto Github PK

View Code? Open in Web Editor NEW
160.0 15.0 50.0 878 KB

The iOS component to connect to a FTP service and perform the operations you need. http://albertodebortoli.github.io/GoldRaccoon/

Home Page: http://albertodebortoli.com

License: Other

Objective-C 98.87% Ruby 1.13%
ftp ios

goldraccoon's Introduction

GoldRaccoon

General Notes

GoldRaccoon is the iOS component to connect to a FTP service and do the following:

  • Download a file
  • Upload a file
  • Delete a file
  • Create a directory
  • Delete a directory
  • List a directory

Why another Raccoon?

First, because the humanity needs it.

This project started on 29/06/2013 for the Objective-C Hackathon (http://objectivechackathon.appspot.com/).

GoldRaccoon aims to be an evolution of BlackRaccoon (which is an evolution of WhiteRaccoon), maybe the best (or at least one of the few) third-party component out there for handling FTP operations on iOS.

I forked the public repo of BlackRaccooon in May 2013 and added some improvements that have been merged into master to BlackRaccoon. Even though BlackRaccoon does what it says, I prefer to clean it a little and use a different and more extensible code structure.

Most of the code is therefore written by Valentin Radu and Lloyd Sargent, the main extensions I (Alberto De Bortoli) added are:

  • Done some deep refactoring for the bloating of the previous code;
  • Added missing (and reasonable) code conventions;
  • Added GRRequestsManager to manage all the different kind of requests using a FIFO queue;
  • Added a demo project.

Usage

If you'd like to include this component as a pod using CocoaPods, just add the following line to your Podfile:

pod "GoldRaccoon"

otherwise

  • copy Sources folder into your project
  • add CFNetwork framework
  • import GRRequestsManager.h in your class
  • add a property for the manager
@property (nonatomic, strong) GRRequestsManager *requestsManager;
  • setup the manager somewhere (with hostname, username and password)
self.requestsManager = [[GRRequestsManager alloc] initWithHostname:<hostname>
                                                              user:<username>
                                                          password:<password>];
  • optionally make your class conform to GRRequestsManagerDelegate, implement the delegate methods (basically success, failure and progress callbacks) and set your instance of this class as delegate for the manager
self.requestsManager.delegate = self;
  • add the requests to the manager using the following methods:
addRequestForListDirectoryAtPath:
addRequestForCreateDirectoryAtPath:
addRequestForDeleteFileAtPath:
addRequestForDeleteDirectoryAtPath:
addRequestForDownloadFileAtRemotePath:toLocalPath:
addRequestForUploadFileAtLocalPath:toRemotePath:
  • start the manager
[self.requestsManager startProcessingRequests];

goldraccoon's People

Contributors

albertodebortoli avatar pk1986 avatar t-oginogin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goldraccoon's Issues

Rename File Request

Hi Alberto,

as not beeing a senior developer in the iOS world I have 2 whishes for GoldRaccoon which I use with great success.

A rename request for a remote file. I tend to upload as .TMP and when finished rename to .PDF (or whatever the extention is). Reason: We hae receiving components in our office running that monitor an FTP folder for new documents and with this I can avoid the PDF beeing pulled into the office system when the iPhone has not successfully finished uploading it.

2)I'd like to add 'something' to a request (a custom structure/object holding additional data of my app belonging to a reuest) so when the didUpload finished I get this extra info back (I add a bunch of upload requests and would like to know the SQLite DB.ID field to update this record when finished uploading and to telete this temporary file. So an object holding ID and FileName (NSMutableArray ?!?) would help very much.

Any chance that you would like to add this to the GoldRaccoon library.
Would be realy great.

Thanks a lot in advance
Ole

Memory Issue

When fetching a directory's contents with about 40k items, my application jumps to about 500mb and crashes. Is there a more memory efficient way of doing this?

Unknown Error

When we try GoldRaccoon to connect our local wifi which is not connected to internet it give same error

crash when copied Sources folder into project

when i copied Sources folder into my project,there are 19 errors,like:
Cannot find interface declaration for 'NSObject', superclass of 'GRError'
Unknown type name 'NSOutputStream'
Property with 'retain (or strong)' attribute must be of object type
Unknown type name 'BOOL'
Unknown type name 'NSOutputStream'
...

can anyone help me

thanks too much

download the file name of chinese ,error

i think is the encoding error,because when i show the file list ,the file name of chinese is
changing to unicode string like '\U00a1\U00a2\U03c0' , but when i decode the unicode string is wrong string . could you find the cause of error. thx

Occasional BAD_EXEC_ACCESS on [readStream open];

So i actually ended up here because I was using Black Raccoon and was having issues (I'm glad i switched over though because I like the gold architecture better). In any case I've been having intermittent issues with line 74 of GRStreamInfo.m

I'm looping through a table and creating temp files on the disk then I loop through and send out each file. With some level of frequency I get a EXEC_BAD_ACCESS call on the line:

[readStream open];

in the code block:

readStream.delegate = request;
[readStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[readStream open];

I really am at a loss. Any ideas?

Threading issues

the downloadRequest will own the main thread .
if hava a lot of downloadRequest to start.
i find the UI will clog

Background Activity

Hi all,

as beeing new I struggle with background upload even when the app is in background (right now it freezes). As I have read this is not wanted by apple besides some exceptions (location, Download, music ...).

Is it possible by any chance to have uploads also continue running in background? What do i have to do to enable this feature - if available?

TIA
Ole

Encoding file names problem

Hello, I'm using your great GoldRaccoon, but I have problem with encoding files names or folders names. For example, when I try to get file name (from listing folder request), I get something like this:
"test ąćę.mp4"
instead of:
"Test ąćę.mp4" (ąćę are polish signs)
And now I cannot download this file, because it has improperly file name.
Is there any way to properly encode string? Does GoldRaccoon support different encoding types?
Any help would be very nice.
Łukasz

second run failed

start downloading file and then abort and then start again. Now it will never work and throws error
Stream timed out with no response from server

Still crashes when uploading files

014-08-22 18:27:20.684 Meety[4223:60b] FAIL: Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "The operation couldn’t be completed. (com.albertodebortoli.goldraccoon error -1000.)" UserInfo=0x9353ba0 {message=Not logged in.}

Code not necessary - it follows demo example.

When uploading many files, host suddenly refuses

I have a strange issue. Everything works and I can upload some a few files before my web host shuts me down. It seems like the web host thinks my activies are suspecious even if I am using correct log in, what could cause this and how can I prevent this?

BUT if I use an FTP-application like Transmit, I have never encountered these problems when uploading more than thousens files to my web host.

I am using this code (simplefied)

self.requestsManager = [[GRRequestsManager alloc] 
                     initWithHostname:self.currentSite.host
                     user:self.currentSite.username
                     password:password];

self.requestsManager.delegate = self;
for(File *file in self.files) {
        [self.requestsManager addRequestForUploadFileAtLocalPath:localFileName
           toRemotePath:remoteFileName];
}
[self.requestsManager startProcessingRequests];

malloc error every time

Hi guys

I'm trying to write an FTP performance test using GoldRaccoon. But I'm finding that I am getting an error stating:
malloc: *** error for object 0x48ba000: pointer being freed was not allocated

I've tried setting a malloc_error_break breakpoint as XCode suggests, but it isn't giving me any help.

I don't know what information you'd need to help out with this. I can post the whole class, just let me know if that would help?

I have implemented @t-oginogin's solution in issue #15 in hopes that it would help, but I think this is a separate issue that I'm getting.

Can't change filename

When I execute this function I can't seem to change the name,if i put any other thing that is not a literal,the image won't upload,Is there any way I can keep the Filename as a variable?

-(void)UploadImage:(NSString )BDPath :(NSString)Filename{
[self _setupManager];
[self.requestsManager addRequestForUploadFileAtLocalPath:BDPath toRemotePath:[NSString stringWithFormat:@"%@",Filename]];
[self.requestsManager startProcessingRequests];
}

Crash in background download.

I am getting below given crash sometimes.
Its not reproducible its random crash.
*** -[GRDownloadRequest respondsToSelector:]: message sent to deallocated instance 0x7a588d70 can u tell steps to reproduce

Stream timeout

It always show in failure response "Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "The operation couldn’t be completed. (com.albertodebortoli.goldraccoon error -1000.)" UserInfo=0x14dd1a20 {message=Stream timed out with no response from server.}"

Please explaine how can fix it
[email protected]

FTP vs SFTP

Hi Alberto,

first of all I'd like to thank your for this great FTP library. I'm new to iOS development (with approx 30 years of experience in windows development) and I appreciate it very much.

I'm developing for our company and they request an SFTP Transfer for security purposes. Would you mind giving me your thoughts and/or tips and trick for getting SFTP to work?

Thanks a lot in advance
Ole

getting connection error

Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=Not logged in.}

GoldRaccoon[2737:90761] requestsManager:didFailRequest:withError:
Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=Not logged in.}
GoldRaccoon[2737:90761] requestsManager:didScheduleRequest:

message=Unknown error!

I just want to do upload only.
I am getting error while uploading "message=Unknown error!"
I m not able to upload to my ftp server .

Please help

Not able to upload. Unknown Error

I am getting below error on upload

requestsManager:didFailRequest:withError:
Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=Unknown error!}

Random Crash with -GRRequestsManager : didFailRequest with error Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=Unable to read from open stream.}

App is crashing while app is in background. NOTE: crash happing with iOS 14 onwards only.
Crash at following lines

  1. -[GRListingRequest stream:handleEvent:]
    With error -GRRequestsManager : didFailRequest with error Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=Unable to read from open stream.}
  2. -[GRStreamInfo close:]
    With error - GRRequestsManager : didFailRequest with error Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=Stream timed out with no response from server.}

The app is calling to upload the file

  • (id)addRequestForUploadFileAtLocalPath:(NSString *)localPath toRemotePath:(NSString *)remotePath;

"message=File or directory not available or directory already exists." message

Hi,
for each action i'm trying executing, i'm getting log message:

requestsManager:didScheduleRequest:
requestsManager:didFailRequest:withError: 
 Error Domain=com.albertodebortoli.goldraccoon Code=-1000 "(null)" UserInfo={message=File or directory not available or directory already exists.}

Unfortunately, it's even for the demo.
any idea ?

Memory pressure while downloading a large size file using GoldRaccoon

I use GoldRaccoon as my 3rd ftp library. When I download large size (> 500MB) file, my app will crash in memory pressure. The snapshot as below that using instrument to detect the memory allocations in my app. How do I handle these allocation when getting low memory warning ??

screen shot 2015-06-29 at 10 14 19 am

Working with wifi only?

It seems like the ftp operation is successful if the device is connected to wifi. While connected 3G network, it throws error.

Is this library supposed to work only with wifi or am i missing something?

upload to ftp is 0 bytes

hi

i connect to my ftp with settings and downloaded successfully but when i try to upload it in a different name it also says completed but in ftp its size is 0.

so i assume that the downloaded file's size is 0 too. my file is a 7kb png file

is there any setting that i can do except host name file path username and password?

Crash when upload file.

Hi Alberto.
I tried uploading a file each 1 minutes. It crashed very often. Here is the image for detail.

screen shot 2013-12-29 at 11 01 54 pm

Trouble uploading multiple files

Im trying to upload multiple images from an array using this method,only the last image in the array is uploaded.

while(list<[images count]) {
NSMutableDictionary *dic = [images objectAtIndex:list];
NSString *displayimg = [dic objectForKey:@"image"];
NSString *Filename = [dic objectForKey:@"Filename"];
NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",Filename]];
[imageData writeToFile:path atomically:YES];
[self.requestsManager addRequestForUploadFileAtLocalPath:path toRemotePath:Filename];
list++;
}
[self.requestsManager startProcessingRequests];

Can't compile Project too many errors

In file included from /Users/developer/Documents/KHOJATV/Sources/Utils/GRError.m:15:
/Users/developer/Documents/KHOJATV/Sources/Utils/GRError.h:41:22: error: cannot find interface declaration for 'NSObject', superclass of 'GRError'
@interface GRError : NSObject

/Users/developer/Documents/KHO/Sources/Utils/GRError.h:44:22: error: unknown type name 'NSString'
@property (readonly) NSString *message;
                     ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.h:46:37: error: expected a type
+ (GRErrorCodes)errorCodeWithError:(NSError *)error;
                                    ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:21:37: error: expected a type
+ (GRErrorCodes)errorCodeWithError:(NSError *)error
                                    ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:34:4: error: expected a type
- (NSString *)message
   ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:24:5: error: use of undeclared identifier 'NSDictionary'
    NSDictionary *userInfo = error.userInfo;
    ^
/Users/developer/Documents/KHOJATV/Sources/Utils/GRError.m:24:19: error: use of undeclared identifier 'userInfo'
    NSDictionary *userInfo = error.userInfo;
                  ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:24:36: error: property 'userInfo' not found on object of type '__strong id'
    NSDictionary *userInfo = error.userInfo;
                                   ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:25:5: error: use of undeclared identifier 'NSNumber'
    NSNumber *code = [userInfo objectForKey:(id)kCFFTPStatusCodeKey];
    ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:25:15: error: use of undeclared identifier 'code'
    NSNumber *code = [userInfo objectForKey:(id)kCFFTPStatusCodeKey];
              ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:25:23: error: use of undeclared identifier 'userInfo'
    NSNumber *code = [userInfo objectForKey:(id)kCFFTPStatusCodeKey];
                      ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:27:9: error: use of undeclared identifier 'code'
    if (code) {
        ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:28:17: error: use of undeclared identifier 'code'
        return [code intValue];
                ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:36:5: error: use of undeclared identifier 'NSString'
    NSString *errorMessage;
    ^
/Users/developer/Documents/KHOJATV/Sources/Utils/GRError.m:36:15: error: use of undeclared identifier 'errorMessage'
    NSString *errorMessage;
              ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:40:13: error: use of undeclared identifier 'errorMessage'
            errorMessage = @"Data is nil.";
            ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:44:13: error: use of undeclared identifier 'errorMessage'
            errorMessage = @"Unable to open stream.";
            ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:48:13: error: use of undeclared identifier 'errorMessage'
            errorMessage = @"Unable to write to open stream.";
            ^
/Users/developer/Documents/KHO/Sources/Utils/GRError.m:52:13: error: use of undeclared identifier 'errorMessage'
            errorMessage = @"Unable to read from open stream.";
            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

Stop / Resume download feature

Hi,
I'm trying to modify the code to support stop/resume download feature. In my app I can stop the download, save the partial data to a file. Then I want to be able to restart the operation and get the rest of data from the remote file using an offset.

In GRStreamInfo.m I added

if (request.readOffset > 0)
{
CFReadStreamSetProperty(readStreamRef, kCFStreamPropertyFileCurrentOffset, (CFNumberRef)[NSNumber numberWithUnsignedLongLong:request.readOffset]);
}

before
self.readStream.delegate = request;
[self.readStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[self.readStream open];

I've added readOffset as a property in GRRequest and the setup looks like this

unsigned long long size = [self.fileHandle seekToEndOfFile]; //can be 0 if the file is empty or > 0 if some data was already downloaded
self.downloadRequest = [[GRDownloadRequest alloc] initWithDelegate:self datasource:self];
self.downloadRequest.path = @"path_to_the_file";
self.downloadRequest.localFilePath = @""; //i don't use this
self.downloadRequest.passiveMode = NO;
self.downloadRequest.readOffset = (unsigned int)size;
[self.downloadRequest start];

But the download always start from the beginning of the remote file. Well, I'm not sure if this is supposed to work anyway (from the docs of the NSStream: "By default, NSStream instances that are not file-based are non-seekable, one-way streams (although custom seekable subclasses are possible). Once the data has been provided or consumed, the data cannot be retrieved from the stream"). Anyone care to comment on this issue? Am I doing some wrong, is there something missing in order to make it work?

Timeout when using mobile network

When connecting to Wi-Fi, downloading files is normal, but when connecting to mobile network, time-out occurs.
Why is this error happening?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.