Just downloaded the ObjectiveC Sample and am trying to build FileServiceMac but the Upload calls are ifdef’d out for iOS only and the project does not build??? So, how do you upload files to the backend from Mac OS X? Is there an ftp option? I want to upload a large library.
Thanks! System looks pretty cool!
Hi Felipe,
This sample works fine for me. Only you should use ‘saveFile:’ method instead ‘upload:’
-(void)uploadFile:(id)sender
{
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseFiles:YES];
[openPanel setAllowsMultipleSelection:YES];
[openPanel beginWithCompletionHandler:^(NSInteger result) {
NSLog(@"save file (0): %ld", (long)result);
if (result == NSOKButton) {
for (NSURL *fileUrl in openPanel.URLs)
{
NSLog(@"save file (1): %@ [%@]", fileUrl, fileUrl.lastPathComponent);
NSData *data = [[NSData alloc] initWithContentsOfURL:fileUrl];
[backendless.fileService
saveFile:fileUrl.lastPathComponent
content:data
response:^(BackendlessFile *f) {
BEFile *file = [BEFile new];
file.path = f.fileURL;
[backendless.persistenceService save:file response:^(id res) {
NSLog(@"save file %@", res);
[_data insertObject:res atIndex:0];
[_tableView beginUpdates];
[_tableView insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:0] withAnimation:NSTableViewAnimationEffectGap];
[_tableView endUpdates];
} error:^(Fault *error) {
NSLog(@"%@", error.detail);
}];
} error:^(Fault *error) {
NSLog(@"%@", error.detail);
}];
}
}
}];
}
Regards,
Slava
Perfect, thanks V! Only thing to fix is the Sample code on your end.