I'm making a client-server program for picking a file from a location on a Mac desktop and then copying it into a iPhone simulator. Then, it'll upload it to the server using the TCP protocol.
Can anyone please suggest how to do it or can suggest a site where I can learn about it. I got the following code on internet, will it perform the above required task?
if ( [[NSFileManager defaultManager] isReadableFileAtPath:source] )
[[NSFileManager defaultManager] copyPath:source toPath:destination handler:nil];
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:foldername destination:@"" files:filenamesArray tag:&tag];
You can use the Files app to access files stored on file servers, other cloud storage providers like Box and Dropbox, and external devices, such as USB drives and SD cards, after you connect them to your iPhone.
Have a look at ASIHTTPRequest: http://allseeing-i.com/ASIHTTPRequest/
Following is the piece of code I use ASIHTTPRequest to upload a file.
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addPostValue:token forKey:@"token"];
[request setFile:recorderFilePath forKey:@"thefile"];
[request startSynchronous];
NOTE, the variable recorderFilePath is the path to a audio file, this is a file I created in app document directory, added following code to your header file, will help you to get your document directory.
#define DOCUMENTS_FOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With