2017-01-11 34 views
12

पर अपलोड करना बंद/रद्द करें मैं फ़ाइल अपलोड करने के लिए AWSLocal सामग्री अपलोड विधि का उपयोग कर रहा हूं। मुझे दूसरी स्क्रीन से अपलोड रद्द करना होगा।एडब्ल्यूएस एस 3

private func uploadLocalContent(localContent: AWSLocalContent) { 
    localContent.uploadWithPinOnCompletion(false, progressBlock: {[weak self](content: AWSLocalContent?, progress: NSProgress?) -> Void in 
     guard let strongSelf = self else { return } 
     dispatch_async(dispatch_get_main_queue()) { 
      // Update the upload UI if it is a new upload and the table is not yet updated 
      if(strongSelf.tableView.numberOfRowsInSection(0) == 0 || strongSelf.tableView.numberOfRowsInSection(0) < strongSelf.manager.uploadingContents.count) { 
       strongSelf.updateUploadUI() 
      } else { 

       for uploadContent in strongSelf.manager.uploadingContents { 
        if uploadContent.key == content?.key { 
         let index = strongSelf.manager.uploadingContents.indexOf(uploadContent)! 
         let indexPath = NSIndexPath(forRow: index, inSection: 0) 
         strongSelf.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .None) 
        } 
       } 
      } 
     } 
     }, completionHandler: {[weak self](content: AWSContent?, error: NSError?) -> Void in 
      guard let strongSelf = self else { return } 
      strongSelf.updateUploadUI() 
      if let error = error { 
       print("Failed to upload an object. \(error)") 
       strongSelf.showSimpleAlertWithTitle("Error", message: "Failed to upload an object.", cancelButtonTitle: "OK") 
      } else { 
       strongSelf.refreshContents() 
      } 
     }) 
    updateUploadUI() 
} 
+0

क्या आप रद्द करने के लिए __need__ को हटा रहे हैं या कॉल कर रहे हैं रिमोट कंटेंट विथ कॉम्प्लेशन हैंडलर अपलोड के बाद और पूरा करने में पर्याप्त नहीं है? –

उत्तर

1

दुर्भाग्य से जब AWSLocalContent से कहा जाता AWTask तक पहुंच नहीं है के रूप में एक अपलोड रोकने का कोई तरीका नहीं:

यहाँ अपलोड करने कार्य है।

AWSS3TransferManager (http://docs.aws.amazon.com/AWSiOSSDK/latest/Classes/AWSS3TransferManager.html#//api/name/upload) में देखें जो प्रत्येक क्रिया के लिए AWTask बनाता है, इसे अपलोड या डाउनलोड किया जा सकता है, जिसे रद्द/रोका/फिर से शुरू किया जा सकता है। इसके अलावा आपको AWSS3TransferManager से सुविधा विधियां मिलती हैं जो सभी कार्यों को एक बार में रद्द/रोक/फिर से शुरू कर सकती हैं।

आपको अपलोडिंग AWTask अपलोड करना होगा, इसे अपनी दूसरी स्क्रीन से कहीं भी सुलभ रखें और फिर आप इसे रद्द कर पाएंगे।

संबंधित मुद्दे