Python 无法将图像发送到我的服务器
无法将映像发送到我的服务器。 无法将图像上载到服务器。我正在制作Swift应用程序,我想在我的应用程序中制作一个系统,将图像上传到我的Django服务器。现在,光控器(用于系统)已启动 此url允许myUrl=NSURL(字符串:“”);是我的服务器的图像上载url。回溯是Python 无法将图像发送到我的服务器,python,ios,swift,django,xcode,Python,Ios,Swift,Django,Xcode,无法将映像发送到我的服务器。 无法将图像上载到服务器。我正在制作Swift应用程序,我想在我的应用程序中制作一个系统,将图像上传到我的Django服务器。现在,光控器(用于系统)已启动 此url允许myUrl=NSURL(字符串:“”);是我的服务器的图像上载url。回溯是 2017-06-14 23:04:50.480209 Kenshin_Swift[262:8094] [Generic] Creating an image format with an unknown type is an
2017-06-14 23:04:50.480209 Kenshin_Swift[262:8094] [Generic] Creating an image format with an unknown type is an error
2017-06-14 23:04:52.660264 Kenshin_Swift[262:8267] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
error=Optional(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=0x174456e90 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}, NSErrorFailingURLStringKey=http://localhost:8000/admin/accounts/post/, NSErrorFailingURLKey=http://localhost:8000/admin/accounts/post/, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.})
我的信息列表是
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.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>CFBundleSignature</key>
<string></string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleDisplayName</key>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string>for photo library</string>
<key>NSCameraUsageDescription</key>
<string>for camera</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
NSAppTransportSecurity
NSExceptionDomains
example.com
n包括多个域
NSTemporary ExceptionalLowsInSecureHttpLoads
NSTemporaryExceptionMinimumTLSVersion
TLSv1.1
CFBundleSignature
cfbundlegetingfostring
CbundleDisplayName
NSPhotoLibraryUsageDescription
用于照片库
NSCameraUsageDescription
照相机
LSApplicationCategoryType
CfBundledDevelopmentRegion
EN
Cbundlexecutable
$(可执行文件名称)
CbundleIdentifier
$(产品\捆绑包\标识符)
CbundleInfo字典版本
6
CFBundleName
$(产品名称)
CbundlePackageType
应用
CbundleShortVersionString
1
循环流化床锅炉
1.
LSREQUIRESPHONEOS
非人类可读版权
UILaunchStoryboardName
发射屏
UIMainstryBoardFile
主要
UIRequiredDeviceCapabilities
armv7
UI支持接口方向
UIInterfaceOrientationPortrait
UIInterface方向和左视图
UIInterfaceOrientationAndscapeRight
UI支持界面方向~ipad
UIInterfaceOrientationPortrait
UIInterfaceOrientation上下方向图
UIInterface方向和左视图
UIInterfaceOrientationAndscapeRight
回溯告诉我我的Info.plist是错误的,但我不知道是什么错了。
当然,我补充道
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.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>
NSAppTransportSecurity
NSExceptionDomains
example.com
n包括多个域
NSTemporary ExceptionalLowsInSecureHttpLoads
NSTemporaryExceptionMinimumTLSVersion
TLSv1.1
到Info.plist,所以我无法理解为什么图像不能发送到我的服务器。我以为这是Info.plist错误,但这个错误在我的服务器上,对吗?我如何修复这个问题 在您的info.plist中
替换这个
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.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>
NSAppTransportSecurity
NSExceptionDomains
example.com
n包括多个域
NSTemporary ExceptionalLowsInSecureHttpLoads
NSTemporaryExceptionMinimumTLSVersion
TLSv1.1
对此
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads
问题是,若您通过域名连接到主机,您需要使用https协议(苹果要求)。如果无法实现https,可以通过http进行连接,但必须使用IP地址。由于是django代码的问题,能否发布服务器(django)代码的某个片段
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>