Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWSS3TransferUtility iOS 13 Download NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it #2105

Closed
tripleA-max opened this issue Dec 10, 2019 · 19 comments
Assignees
Labels
pending-community-response Issue is pending response from the issue requestor s3 Issues related to S3

Comments

@tripleA-max
Copy link

Describe the bug
My application is using the S3 transfer utility to download a file from S3. On xcode simulators running iOS 13.2.2, there appears to be no issue with download. However, when the application is run ad hoc on a device of the same OS version, the download fails and the error reads as follows: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn’t be opened because you don’t have permission to view it." UserInfo={Server=AmazonS3, Accept-Ranges=bytes, Content-Type=application/json.. etc). This has been a problem since updating my device to iOS 13. After checking with the AWS Cognito and S3 support teams, it was concluded to be an issue with the SDK.
To Reproduce
Steps to reproduce the behavior:

  1. Create a test application with auth using Cognito User Pool as the Identity Provider
  2. Use the S3 transfer utility in your application to download files from S3
  3. Plug in your device and select it as the target to your application on
  4. Build and run your application
  5. See error
  6. Change you target to an xcode simulator
  7. Run again
  8. See no error

Which AWS service(s) are affected?

Expected behavior
The file from S3 should download.

Environment(please complete the following information):

  • SDK Version: 2.12.2
  • Dependency Manager: Cocoapods
  • Swift Version : 4.0

Device Information (please complete the following information):

  • Device: iphoneXsMax, iPhone11 pro simulator
  • iOS Version: 13.2.2
@tripleA-max tripleA-max changed the title iOS 13 S3 Transfer Utility Download NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it AWSS3 Transfer Utility OS 13 Download NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it Dec 10, 2019
@tripleA-max tripleA-max changed the title AWSS3 Transfer Utility OS 13 Download NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it AWSS3TransferUtility OS 13 Download NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it Dec 10, 2019
@tripleA-max tripleA-max changed the title AWSS3TransferUtility OS 13 Download NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it AWSS3TransferUtility iOS 13 Download NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it Dec 10, 2019
@lawmicha lawmicha added the s3 Issues related to S3 label Dec 26, 2019
@lawmicha
Copy link
Member

hi @tripleA-max ,

Thanks for reporting the issue, could you provide a code snippet of how you are trying to download the file? Or even a sample app repo that we can use to reproduce the issue?

@PrekshyaBasnet
Copy link

I am having the same issue. With updated iOS 13, I am not able to download images or audio urls form the server. Same code is working for iOS 12.

@PrekshyaBasnet
Copy link

My issue is solved. I had a custom xcconfig file setup for bundle identifier so referencing that file from Info.plist had caused this error.

@tripleA-max
Copy link
Author

My issue is solved. I had a custom xcconfig file setup for bundle identifier so referencing that file from Info.plist had caused this error.
@PrekshyaBasnet
Can you detail how you fixed this?

@tripleA-max
Copy link
Author

hi @tripleA-max ,

Thanks for reporting the issue, could you provide a code snippet of how you are trying to download the file? Or even a sample app repo that we can use to reproduce the issue?

@kneekey23

let transferUtility = AWSS3TransferUtility.default()
var completionHandler: AWSS3TransferUtilityDownloadCompletionHandlerBlock?
let completion: AWSS3TransferUtilityDownloadCompletionHandlerBlock = { (task, URL, data, error) -> Void in
print(data)
guard let data = data else {
NSLog("Result: (URL), Error :(error)")
return
}
NSLog("File downloaded - (data)")
guard let stringify = String(data: data, encoding: String.Encoding.utf8) else { return }
DispatchQueue.main.async {
self.deserialize(myStringData: stringify, brand: self.brand)
}
}

@PrekshyaBasnet
Copy link

My issue is solved. I had a custom xcconfig file setup for bundle identifier so referencing that file from Info.plist had caused this error.
@PrekshyaBasnet
Can you detail how you fixed this?

So I have a xcconfig file that my app reads App_name, Colors, etc from.
I had added App_Bundle_Identifier = "com.example.A" in the configuration file and so change the info.plist to read from this config file as:

Screen Shot 2020-03-03 at 12 15 37 pm

So I changed

Screen Shot 2020-03-03 at 12 16 48 pm

And it worked. I debugged for the whole day just to find, that change had caused permission error in iOS 13.

@tripleA-max
Copy link
Author

@PrekshyaBasnet Thank you so much for this explanation. This did not seem to be the issue for me. My bundle identifier is and has always been $(PRODUCT_BUNDLE_IDENTIFIER) as I did not use an xcconfig file. I'm afraid this was not the solution to my problem. Thank you for your timely response though, it was very much appreciated.

@lawmicha
Copy link
Member

lawmicha commented Mar 3, 2020

hi @tripleA-max,
from your code snippet

let transferUtility = AWSS3TransferUtility.default()
var completionHandler: AWSS3TransferUtilityDownloadCompletionHandlerBlock?
let completion: AWSS3TransferUtilityDownloadCompletionHandlerBlock = { (task, URL, data, error) -> Void in
    print(data)
    guard let data = data else {
        NSLog("Result: (URL), Error :(error)")
        return
    }
    NSLog("File downloaded - (data)")
    guard let stringify = String(data: data, encoding: String.Encoding.utf8) else { return }
    DispatchQueue.main.async {
        self.deserialize(myStringData: stringify, brand: self.brand)
    }
}

Can you clarify what is the call you are making with transferUtility? The completion handler does look correct, that you can processing data only when there is no error.

You also mentioned this is working on the simulator and not on the device, and that this is related to file permissions. Are you downloading the object stored in S3 down to a specific URL?

Feel free to try out this sample to see if you can find any differences between your calling pattern and the one from the sample: https://github.com/awslabs/aws-sdk-ios-samples/tree/master/S3TransferUtility-Sample/Swift

For example, to download data specified by a key in S3, you can check out https://github.com/awslabs/aws-sdk-ios-samples/blob/master/S3TransferUtility-Sample/Swift/S3BackgroundTransferSampleSwift/DownloadViewController.swift

@tripleA-max
Copy link
Author

tripleA-max commented Mar 4, 2020

Hi,
@lawmicha thanks for the response!
I modified my code to match the implementation you provided in the samples but I am still experiencing this issue. The call I am making is a download data request to an existing S3 bucket.

transferUtility.downloadData( fromBucket: bucketName, key: keyName, expression: nil, completionHandler: completionHandler).continueWith { (task) -> AnyObject? in if let error = task.error { NSLog("Error: \(error.localizedDescription)") } if let _ = task.result { NSLog("Download Starting!") } return nil; } }

The transfer utility download does work on any device running iOS 12 or lower and on an iOS 13 sim. It's just a physical device running iOS13 where it doesn't.

@lawmicha
Copy link
Member

lawmicha commented Mar 5, 2020

maybe be related #2314

@PrekshyaBasnet
Copy link

@tripleA-max This issue is really strange cause the issue in iPad still persists. But the issue does not exist for iPhone anymore.

@lawmicha lawmicha assigned lawmicha and phani-srikar and unassigned wooj2 and lawmicha Mar 6, 2020
@tripleA-max
Copy link
Author

@PrekshyaBasnet Oh no way. Yea something with the SDK then maybe. Thank you so much for your feedback!

@lawmicha
Copy link
Member

lawmicha commented Mar 7, 2020

The transfer utility download does work on any device running iOS 12 or lower and on an iOS 13 sim. It's just a physical device running iOS13 where it doesn't.

Hi @tripleA-max , we just tried using the sample app and running it on a physical device on iOS 13.3.1 and things look fine. Could it be a setting on your device that is retricting some file permissions?

It appears you are also using an older SDK version, can you try again with the latest version? 2.13.0

Can you clarify, if the file permission error is coming from TransferUtility or after you have downloaded the data and writing to a file yourself? Did you reproduce this on the sample app or your own app?

@tripleA-max
Copy link
Author

tripleA-max commented Mar 9, 2020

Could it be a setting on your device that is retricting some file permissions?

Hi @lawmicha I thought that could be the issue, but it just isn't my device that has this issue. Any device I use running iOS 13 gives me this problem. I updated awhile back and I am using Cocoapods 2.12.7 and I am still seeing the issue. The error comes back from the AWSS3TransferUtilityDownloadCompletionHandlerBlock. The file that is being downloaded is being downloaded for the sake of displaying its contents, not to be saved or written to.

@PrekshyaBasnet Can you provide any more info on your issue with iPad?

@PrekshyaBasnet
Copy link

PrekshyaBasnet commented Mar 9, 2020

@tripleA-max
I have two targets, client1-app and client2-app. Both were not working for iOS 13+ in iPhone and iPad.

I updated referencing the bundle Id in info.plist -> #2105 (comment), and it started working on iPhone and not in iPad.
So I suspected there is issue related with info.plist and not anywhere.

Yesterday just for testing, I changed the bundle id and ran on the iPad and it works. So my issue was all related to info.plist.

Can you try changing bundle id and just see if it works that way? Just to see if its info.plist related problem.

@phani-srikar
Copy link
Contributor

Hi @tripleA-max
This looks like an issue with Info.plist rather than a bug in SDK.
Here are some resources that might help:
com_apple_developer_default-data-protection
encrypting_your_app_s_files

@lawmicha lawmicha added pending-community-response Issue is pending response from the issue requestor closing-soon-if-no-response labels Apr 2, 2020
@stale
Copy link

stale bot commented Apr 9, 2020

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

@stale stale bot closed this as completed Apr 9, 2020
@julien-tamade
Copy link

Hi, I'm wondering if you solved the issues @tripleA-max ? I'm experiencing this as well

@jorgenfaunaapp
Copy link

jorgenfaunaapp commented Jul 27, 2023

I have experienced this issue and have been troubleshooting for way too many hours... My issues were apparently also caused by some mistake in my bundle identifier in my plist info file as described by @PrekshyaBasnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-community-response Issue is pending response from the issue requestor s3 Issues related to S3
Projects
None yet
Development

No branches or pull requests

8 participants