1

I use an SDK (YITechnology) but I have a problem to download videos that exceeds 40mb size. When I use that code in the ViewController, videos less than 40mb are okay. The problem is that if they are bigger than 40mb, it stops. How can I tell it to continue to download? I tried that ticket but it is not exactly the same thing...

ActionCamera:

@objc public class ActionCamera : NSObject, URLSessionDownloadDelegate {
public func downloadFile(fileName: String, destFilePath: String, success: ((YICameraSDK.DownloadTask) -> ())?, fail: ((Error) -> ())?) -> YICameraSDK.ActionCamera

    /// Cancel current download task.
    public func cancelDownlad() -> YICameraSDK.ActionCamera

     /// Download file from camera.
///
/// - Parameters:
///     - fileName: The file you want to download from camera.
///     - destFilePath: The file destination file path. Need to be a full path.
///     - success: This callback will be invoked multiple times to notify the progress.
///     - fail: This callback will be invoked if download failed.
public func downloadFile(fileName: String, destFilePath: String, success: ((YICameraSDK.DownloadTask) -> ())?, fail: ((Error) -> ())?) -> YICameraSDK.ActionCamera


    public func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL)

    public func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64)

    public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?)
}

ViewController.swift:

private var mCamera: ActionCamera!;

self.mCamera.downloadFile(fileName: lastFileName, destFilePath: originPath, success:
            {
                downloadTask in
                self.testLbl.text = String(describing: downloadTask.downloadedBytes)



        } , fail: {
            error in

            let alert = UIAlertView();
            alert.message = error as? String;
            alert.addButton(withTitle: "Ko")
            alert.show()
        });

I think it is easy for someone that is familiar with the UrlSession, but it is not my case...

ΩlostA
  • 2,501
  • 5
  • 27
  • 63
  • Please try with other videos and check the server. Sometimes there might be server stuck – Myaaoonn Oct 29 '18 at 11:00
  • For downloadFile method you have not added any code so can't really say what is the problem. You can directly use NSURLSession download task for larger videos. Its very simple. – vivekDas Oct 29 '18 at 11:01

0 Answers0