I am using NMSSH library to upload file to a SFTP server. The file upload works fine as long as the phone is on but whenever I close the screen or minimise the app the upload seems to fail. Can some one please help with this issue. Here is the code i have at the moment.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
client.delegate = self;
BOOL result = [client sftpUpload:filePath toPath:path];
if (result) {
callback(#[]);
} else {
if (client._uploadContinue) {
NSLog(#"Error uploading file");
callback(#[[NSString stringWithFormat:#"Failed to upload %# to %#", filePath, path]]);
} else {
callback(#[#"Upload canceled"]);
}
}
});
Any help would be greatly appreciated. Thanks in advance.
Related
I am using twilio chat SDK, in that I am doing store and retrieve the image.
So to retrieve the image from twilio I am getting NSOutputStream, And I don't know that how to convert NSOutputStream to image. Please see the below code which provided by twilio and give me some suggestions.
chatCell.message = message.body;
if (message.hasMedia) {
NSLog(#"mediaFilename: %# (optional)", message.mediaFilename);
NSLog(#"mediaSize: %lu", (unsigned long)message.mediaSize);
// Set up output stream for media content
NSString *tempFilename = [NSTemporaryDirectory() stringByAppendingPathComponent:message.mediaFilename ? #"file.dat" : message.mediaFilename];
NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:tempFilename append:NO];
// Request the start of the download
[message getMediaWithOutputStream:outputStream
onStarted:^{
// Called when download of media begins.
} onProgress:^(NSUInteger bytes) {
// Called as download progresses, with the current byte count.
} onCompleted:^(NSString * _Nonnull mediaSid) {
// Called when download is completed, with the new mediaSid if successful.
// Full failure details will be provided through the completion block below.
} completion:^(TCHResult * _Nonnull result) {
if (!result.isSuccessful) {
NSLog(#"Download failed: %#", result.error);
} else {
NSLog(#"Download successful");
NSLog(#"%#",message.body);
}
}];
}
I am not sure how to get an image after download complete successful. Please help me to fix this.
Thanks in advance.
I want to upload some files to iCloud and use this:
FileDocument *doc = [[FileDocument alloc] initWithFileURL:des];
doc.data = [NSData dataWithContentsOfURL:src];
NSLog(#"Local url: %#", src);
NSLog(#"Remote url: %#", des);
[doc saveToURL:des forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
if (success) {
NSLog(#"Success");
} else {
NSLog(#"Fail ");
}
}];
After the success log, I open iCloud > Storage > Manage Storage on my iPad to check if file exist. Sometimes the file appear and sometimes not.
I'm trying to upload image to Adobe Creative Cloud using method create:folder:dataPath:contentType:progressBlock:successBlock:cancellationBlock:errorBlock of AdobeAssetFile. File upload succesfully, but I can't track upload progress with progressBlock. This block just don't invocated.
- (void)sendImageWithURL:(NSURL *)imageURL {
NSString *imageName = [imageURL lastPathComponent];
[AdobeAssetFile create:imageName
folder:[AdobeAssetFolder root]
dataPath:imageURL
contentType:[AdobeAssetMimeTypes mimeTypeForExtension:#"jpg"]
collisionPolicy:AdobeAssetFileCollisionPolicyAppendUniqueNumber
progressBlock:^(double fractionCompleted) {
NSLog(#"Progress: %f", fractionCompleted);
}
successBlock:^(AdobeAssetFile *file) {
NSLog(#"Operation is complete");
}
cancellationBlock:^{
NSLog(#"Operation is canceled");
}
errorBlock:^(NSError *error){
NSLog(#"Error is occur: %#", error.localizedDescription);
}
];
}
What's wrong with this code? And why progressBlock not invocated?
I'm using Adobe Creative SDK v0.13.2139.
There is nothing wrong with your code. This is a known issue. A fix is in the works.
I need to use SoundCloud SDK into a Swift. Does someone have experience in this?
I have problem even at the start of their integration guide: https://developers.soundcloud.com/docs/api/ios-quickstart#authentication
When, in AppDelegate, I write
var scurl: NSURL
scUrl = NSURL(string: "www.francescocrema.it")!
SCSoundCloud.setClientID(idCode,secret: secCode, redirectURL: scUrl)
when it gets executed, the app crashed with SIGABRT and no visible error!
Plus, I can't manage to translate this code to Swift
- (IBAction) login:(id) sender
{
SCLoginViewControllerCompletionHandler handler = ^(NSError *error) {
if (SC_CANCELED(error)) {
NSLog(#"Canceled!");
} else if (error) {
NSLog(#"Error: %#", [error localizedDescription]);
} else {
NSLog(#"Done!");
}
};
[SCSoundCloud requestAccessWithPreparedAuthorizationURLHandler:^(NSURL *preparedURL) {
SCLoginViewController *loginViewController;
loginViewController = [SCLoginViewController
loginViewControllerWithPreparedURL:preparedURL
completionHandler:handler];
[self presentModalViewController:loginViewController animated:YES];
}];
}
Does someone know more about SoundCloud API?
Could you help me?
I am afraid SoundCloud API is not longer maintain by its team. I would recommend you to use your own library. I am using SoundCloud API as well so I decided to create one, maybe it can be useful for you.
ABMSoundCloudAPI on Github
Your redirectURL is invalid. SCRequest requires a URL with the scheme https:
NSAssert1([[aResource scheme] isEqualToString:#"https"], #"Resource '%#' is invalid because the scheme is not 'https'.", aResource);
Your Swift presentation code might look like this:
SCSoundCloud.requestAccess { (url) in
let loginViewController = SCLoginViewController(preparedURL: preparedUrl, completionHandler: nil)
self.present(loginViewController, animated: true)
}
I'm using SCShareViewController from SoundCloud API in my project (iOS 7.0) so that the user can share your audio on SoundCloud AND on Facebook through the SoundCloud UI.
The upload in SoundCloud is working perfectly! But the share on facebook is not working =/
Does anyone can help me with this?
Is it necessary for me to create an app on facebook? Or does it already use SoundCloud's instead?
EDIT:
Here is my code:
NSURL *trackURL = [NSURL fileURLWithPath:trackPath];
SCShareViewController *shareViewController;
shareViewController = [SCShareViewController shareViewControllerWithFileURL:trackURL
completionHandler:^(NSDictionary *trackInfo, NSError *error){
if (SC_CANCELED(error)) {
NSLog(#"Canceled!");
} else if (error) {
NSLog(#"Ooops, something went wrong: %#", [error localizedDescription]);
} else {
NSLog(#"Uploaded track: %#", trackInfo);
}
}];
[self presentModalViewController:shareViewController animated:YES];