如何使用Xcode 7显示S3存储桶中的图像?

时间:2015-11-19 10:38:31

标签: ios xcode amazon-s3 xcode7

我正在使用Amazon S3存储桶来保存图像,它在Xcode 6中工作正常但在升级到Xcode 7之后,应用程序没有显示图像。但是当我启用NSAppTransportSecurity安全性并且它正常工作时。

如果没有应用程序传输安全性,我怎样才能让它工作?

1 个答案:

答案 0 :(得分:0)

您需要为托管图片的服务器添加例外,或者允许所有任意加载到您应用的plist文件。 iOS 9及更高版本需要NSAppTransportSecurity

例外:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>download.yourServer.com.s3.amazonaws.com</key>
    <dict>
      <!--Include to allow subdomains-->
      <key>NSIncludesSubdomains</key>
      <true/>
      <!--Include to allow HTTP requests-->
      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <!--Include to specify minimum TLS version-->
      <key>NSTemporaryExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
    </dict>
  </dict>
</dict>

允许所有连接:

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>