1

我是 Swift 的新手。由于我更新了 podfile,我在 AWSS3 中遇到了问题

Cannot find type 'AWSS3TransferManagerUploadRequest' in scope
Cannot find type 'AWSS3TransferManagerDownloadRequest' in scope

ViewController中也有import AWSS3

我不明白这个问题。有人面临同样的问题吗?

我也检查这个https://stackoverflow.com/questions/32659346/awss3transfermanageruploadrequest-in-xcode-7

但这无济于事。

    var uploadRequests = Array<AWSS3TransferManagerUploadRequest?>()
    var uploadFileURLs = Array<URL?>()    
    var downloadRequests = Array<AWSS3TransferManagerDownloadRequest?>()
    
        func download(_ downloadRequest: AWSS3TransferManagerDownloadRequest) {
            switch (downloadRequest.state) {
            case .notStarted, .paused:
                let transferManager = AWSS3TransferManager.default()
                transferManager.download(downloadRequest).continueWith(block: { (task) -> AWSTask<AnyObject>? in
                    if let error = task.error {
                        if error.domain == AWSS3TransferManagerErrorDomain as String
                            && AWSS3TransferManagerErrorType(rawValue: error.code) == AWSS3TransferManagerErrorType.paused {
                            print("Download paused.")
                        } else {
                            print("download failed: [\(error)]")
                        }
                    } else if let exception = task.error {
                        print("download failed: [\(exception)]")
                    } else {
                        DispatchQueue.main.async(execute: { () -> Void in
                            print("downloaded file url: \(downloadRequest.downloadingFileURL)")
    //                        if let index = self.indexOfDownloadRequest(self.downloadRequests, downloadRequest: downloadRequest) {
    //                            self.downloadRequests[index] = nil
    //                            self.downloadFileURLs[index] = downloadRequest.downloadingFileURL
    //                            
    //                            let indexPath = NSIndexPath(forRow: index, inSection: 0)
    //                            self.collectionView.reloadItemsAtIndexPaths([indexPath])
    //                        }
                        })
                    }
                    return nil
                })
                
                break
            default:
                break
            }
        }
        func downloadAll() {
            for (_, value) in self.downloadRequests.enumerated() {
                if let downloadRequest = value {
                    if downloadRequest.state == .notStarted
                        || downloadRequest.state == .paused {
                        self.download(downloadRequest)
                    }
                }
            }
            
    //        self.collectionView.reloadData()
        }

func listObjects() {
        let s3 = AWSS3.default()
        
        let listObjectsRequest = AWSS3ListObjectsRequest()
        listObjectsRequest?.bucket = "dice-ios"
        s3.listObjects(listObjectsRequest!).continueWith { (task) -> AnyObject? in
            if let error = task.error {
                print("listObjects failed: [\(error)]")
            }
            if let exception = task.error {
                print("listObjects failed: [\(exception)]")
            }
            if let listObjectsOutput = task.result {
                if let contents = listObjectsOutput.contents {
                    for s3Object in contents {
                        
                        let downloadingFileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("download").appendingPathComponent(s3Object.key!)
                        let downloadingFilePath = downloadingFileURL.path
                        
                        if FileManager.default.fileExists(atPath: downloadingFilePath) {
                            self.downloadRequests.append(nil)
                            self.downloadFileURLs.append(downloadingFileURL)
                        } else {
                            let downloadRequest = AWSS3TransferManagerDownloadRequest()
                            downloadRequest?.bucket = "dice-ios"
                            downloadRequest?.key = s3Object.key
                            downloadRequest?.downloadingFileURL = downloadingFileURL
                            
                            self.downloadRequests.append(downloadRequest)
                            self.downloadFileURLs.append(nil)
                        }
                    }
                    
                    DispatchQueue.main.async(execute: { () -> Void in
//                        self.collectionView.reloadData()
                    })
                }
            }
            return nil
        }
    }

我的代码是这样的,因为我更新了 podfile,所以我遇到了问题。我在 AWS3 更新时遇到了问题。我需要知道要更换什么。

4

1 回答 1

0

您需要降级 AWSS3 pod 版本。检查 pod 文件夹以查看您正在使用的工具是否存在(在我的情况下,AWSS3TransferManager.h 从当前版本中丢失,降级到具有它的版本)。

于 2022-01-05T14:10:56.843 回答