ko2ic / image_downloader

Flutter plugin that downloads images and movies on the Internet and saves to Photo Library on iOS or specified directory on Android.
https://pub.dartlang.org/packages/image_downloader#-readme-tab-
MIT License
92 stars 116 forks source link

Ios can't download image because of security policy #11

Closed doomsdayer closed 5 years ago

doomsdayer commented 5 years ago

Ios emulater, when starting download, get these error:

Unsupported value: Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x600001028780 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}, NSErrorFailingURLStringKey=http://pic.cdn.5nuthost.com/imgflip/289098e09642b1b463c3acee77a503db.jpg, NSErrorFailingURLKey=http://pic.cdn.5nuthost.com/imgflip/289098e09642b1b463c3acee77a503db.jpg, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.} of type NSURLError

solution: edit the Info.plist, add these:

  <key>NSAppTransportSecurity</key>  
  <dict>  
    <key>NSAllowsArbitraryLoads</key>
    <true/>  
  </dict>
ko2ic commented 5 years ago

@doomsdayer Thank you for comments. As you probably know, in the case of HTTP you need to set the policy of ATS(App Transport Security). This is irrelevant for image_downloder. It is the specification of ios.

However, flutter users may not be familiar with ios, so I thought that it was necessary to write in README as well.

k3v1n-uncle commented 4 years ago

the ios still have this problem,i set info.plist already `NSAppTransportSecurity

NSExceptionDomains ***.com NSExceptionAllowInsecureHTTPLoads NSAllowsArbitraryLoads NSAllowsArbitraryLoadsInWebContent ` Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.14.6 18G3020, locale zh-Hans-CN) • Flutter version 1.12.13+hotfix.8 at /Users/iosappjingda/Documents/flutter • Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0 [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/iosappjingda/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 11.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3.1, Build version 11C504 • CocoaPods version 1.8.4 [✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 43.0.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)