阅读背景:

从S3Bucket下载的部分图像在AWS IOS SDK中显示为黑色

来源:互联网 

I am using the following code to download the image from S3Bucket using AWS IOS SDK

我使用以下代码使用AWS IOS SDK从S3Bucket下载映像

      let s3BucketName = "mybucket"
        let fileName = "filename.png"

        let downloadFilePath = documentDirectory.stringByAppendingPathComponent(fileName)
        let downloadingFileURL = NSURL.fileURLWithPath(downloadFilePath)

        let downloadRequest = AWSS3TransferManagerDownloadRequest()
        downloadRequest.bucket = s3BucketName
        downloadRequest.key  = "\(folder)\(fileName)"
        downloadRequest.downloadingFileURL = downloadingFileURL

         transferManager.download(downloadRequest).continueWithSuccessBlock({
            (task: BFTask!) -> BFTask! in
            dispatch_async(dispatch_get_main_queue(), {

                var image = UIImage(named: "\(documentDirectory)/\(fileName)")
                imageView.image = image
                loaderCellView.hidden = true
            })
            return nil
        })

whenever the image is getting downloaded some portion of the image is getting black. But when I look at the image in S3 Bucket then it is properly shown there. this happens sometimes and sometimes not. So I am looking for the solution. See the attached picture. Can anyone help me for this? I will be really greatfull for this.

每当图像被下载时,图像的某些部分变黑。但是当我在S3 Bucket中查看图像时,它会在那里正确显示。这种情况有时发生,有时不发生所以我正在寻找解决方案。见附图。任何人都可以帮助我吗?我会非常满意。

1 个解决方案

#1


0  

I solved it myself. I upgraded my AWS SDK and replaced BFTask with AWSTask. It worked like a charm for me. AWS has introduced new individual framework AWSMobileAnalytics.framework which has introduced AWSTask in place of Bolt's BFTask. So it is no more dependent on Bolt framework to run background process for uploading or downloading files as from now AWS has now independent framework AWSMobileAnalytics.framework for that. Download latest SDK. Delete all json that were contained in old SDK. Then delete all the framework files of old SDK. Then add all the framework files from "frameworks" folder in the newly downloaded SDK. In the bridging header you just need to change the line "#import < AWSCore/ AWSCore.h>" to "#import < AWSMobileAnalytics/ AWSMobileAnalytics.h>". Hope it will help anyone facing the same problem.

我自己解决了。我升级了我的AWS SDK并用AWSTask替换了BFTask。它对我来说就像一个魅力。 AWS推出了新的个人框架AWSMobileAnalytics.framework,它引入了AWSTask代替Bolt的BFTask。因此,从现在起,AWS现在已经拥有独立的框架AWSMobileAnalytics.framework,因此不再依赖Bolt框架来运行上传或下载文件的后台进程。下载最新的SDK。删除旧SDK中包含的所有json。然后删除旧SDK的所有框架文件。然后在新下载的SDK中添加“frameworks”文件夹中的所有框架文件。在桥接头中,您只需将“#import ”行更改为“#import ”。希望它能帮助任何面临同样问题的人。


分享到: