{"id":3124,"date":"2021-06-08T13:19:44","date_gmt":"2021-06-08T05:19:44","guid":{"rendered":"http:\/\/123.57.164.21\/?p=3124"},"modified":"2021-07-10T09:54:56","modified_gmt":"2021-07-10T01:54:56","slug":"swift-%e5%ae%9e%e7%8e%b0%e5%a4%a7%e6%96%87%e4%bb%b6%e7%9a%84%e5%90%8e%e5%8f%b0%e4%b8%8a%e4%bc%a0%e5%8a%9f%e8%83%bd%ef%bc%88%e9%99%84%e6%a0%b7%e4%be%8b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=3124","title":{"rendered":"Swift &#8211; \u5b9e\u73b0\u5927\u6587\u4ef6\u7684\u540e\u53f0\u4e0a\u4f20\u529f\u80fd\uff08\u9644\u6837\u4f8b\uff09"},"content":{"rendered":"\n<p>&nbsp; &nbsp; \u6211\u4e4b\u524d\u5199\u8fc7\u4e00\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u5982\u4f55\u5b9e\u73b0\u5927\u6587\u4ef6\u7684\u540e\u53f0\u4e0b\u8f7d\uff08<a rel=\"noreferrer noopener\" href=\"https:\/\/www.hangge.com\/blog\/cache\/detail_2203.html\" target=\"_blank\">\u70b9\u51fb\u67e5\u770b<\/a>\uff09\uff0c\u672c\u6587\u63a5\u7740\u6f14\u793a\u540e\u53f0\u4e0a\u4f20\u529f\u80fd\u3002\u4e5f\u5c31\u662f\u8bf4\u5f53\u7a0b\u5e8f\u9000\u5230\u540e\u53f0\uff08\u6bd4\u5982\u6309\u4e0b&nbsp;<strong>home&nbsp;<\/strong>\u952e\u3001\u6216\u8005\u5207\u5230\u5176\u5b83\u5e94\u7528\u4e0a\uff09\u65f6\uff0c\u5f53\u524d\u7684\u4e0a\u4f20\u4efb\u52a1\u4e0d\u4f1a\u7acb\u523b\u505c\u6b62\uff0c\u800c\u662f\u4f1a\u7ee7\u7eed\u8fdb\u884c\u3002<br><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">1\uff0c\u5b9e\u73b0\u539f\u7406<\/h5>\n\n\n\n<p>\uff081\uff09<strong>URLSessionConfiguration&nbsp;<\/strong>\u6709\u5982\u4e0b\u4e09\u79cd\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ul><li><strong>default<\/strong>\uff1a\u9ed8\u8ba4\u4f1a\u8bdd\u6a21\u5f0f\uff08\u4f7f\u7528\u7684\u662f\u57fa\u4e8e\u78c1\u76d8\u7f13\u5b58\u7684\u6301\u4e45\u5316\u7b56\u7565\uff09<\/li><li><strong>ephemeral<\/strong>\uff1a\u6682\u65f6\u4f1a\u8bdd\u6a21\u5f0f\uff08\u8be5\u6a21\u5f0f\u4e0d\u4f7f\u7528\u78c1\u76d8\u4fdd\u5b58\u4efb\u4f55\u6570\u636e\u3002\u800c\u662f\u4fdd\u5b58\u5728&nbsp;<strong>RAM&nbsp;<\/strong>\u4e2d\uff0c\u56e0\u6b64\u5f53\u7a0b\u5e8f\u4f7f\u4f1a\u8bdd\u65e0\u6548\uff0c\u8fd9\u4e9b\u7f13\u5b58\u7684\u6570\u636e\u5c31\u4f1a\u88ab\u81ea\u52a8\u6e05\u7a7a\u3002\uff09<\/li><li><strong>background<\/strong>\uff1a\u540e\u53f0\u4f1a\u8bdd\u6a21\u5f0f\uff08\u8be5\u6a21\u5f0f\u53ef\u4ee5\u5728\u540e\u53f0\u5b8c\u6210\u4e0a\u4f20\u548c\u4e0b\u8f7d\uff09<\/li><\/ul>\n\n\n\n<p>\uff082\uff09\u4e4b\u524d\u6211\u4eec\u4f7f\u7528\u7684\u90fd\u662f&nbsp;<strong>default&nbsp;<\/strong>\u6a21\u5f0f\uff0c\u8981\u5b9e\u73b0\u540e\u53f0\u4e0a\u4f20\u5c31\u5fc5\u987b\u4f7f\u7528&nbsp;<strong>background&nbsp;<\/strong>\u6a21\u5f0f\uff1a<\/p>\n\n\n\n<ul><li>\u5f53&nbsp;<strong>app&nbsp;<\/strong>\u88ab\u7ec8\u6b62\u65f6\uff0c\u7cfb\u7edf\u4f1a\u63a5\u7ba1\u4e0a\u4f20\u4efb\u52a1\u3002<\/li><li>\u7b49\u5230\u4e0a\u4f20\u5b8c\u6210\u6216\u9700\u8981&nbsp;<strong>app&nbsp;<\/strong>\u5173\u6ce8\u65f6\uff0c\u7cfb\u7edf\u53c8\u4f1a\u5728\u540e\u53f0\u5524\u9192&nbsp;<strong>app<\/strong>\uff08\u6ce8\u610f\u662f\u540e\u53f0\u5524\u9192\uff0c\u8be5&nbsp;<strong>app&nbsp;<\/strong>\u4e0d\u4f1a\u5207\u6362\u5230\u524d\u53f0\u663e\u793a\uff09\u3002<\/li><li>\u7136\u540e&nbsp;<strong>app&nbsp;<\/strong>\u518d\u8fdb\u884c\u540e\u7eed\u5904\u7406\u3002<\/li><\/ul>\n\n\n\n<p><strong>\u7279\u522b\u6ce8\u610f<\/strong>\uff1a\u5982\u679c\u5e94\u7528\u88ab\u5f3a\u5236\u5173\u95ed\uff08\u53cc\u51fb&nbsp;<strong>home&nbsp;<\/strong>\u8c03\u51fa\u540e\u53f0\u5217\u8868\uff0c\u5e76\u5c06\u5176\u4e0a\u6ed1\u5173\u95ed\uff09\uff0c\u90a3\u4e48\u540e\u53f0\u4e0b\u8f7d\u5c31\u4e0d\u518d\u8d77\u4f5c\u7528\u4e86\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">2\uff0c\u51c6\u5907\u5de5\u4f5c<\/h5>\n\n\n\n<p>\uff081\uff09\u4e3a\u65b9\u4fbf\u4f7f\u7528\uff0c\u9996\u5148\u6211\u4eec\u5c01\u88c5\u4e00\u4e2a\u540e\u53f0\u4e0a\u4f20\u7684\u5de5\u5177\u7c7b\uff08<strong>UploadManager.swift<\/strong>\uff09,\u5177\u4f53\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul><li>\u521b\u5efa\u4e00\u4e2a&nbsp;<strong>background&nbsp;session&nbsp;<\/strong>\u7528\u4e8e\u540e\u53f0\u4e0a\u4f20\uff08\u9700\u6307\u5b9a\u4e00\u4e2a&nbsp;<strong>identifier<\/strong>\uff09<\/li><li>\u5b9e\u73b0&nbsp;<strong>URLSessionDelegate<\/strong>\u3001<strong>URLSessionDownloadDelegate&nbsp;<\/strong>\u76f8\u5173\u7684\u4ee3\u7406\u534f\u8bae\u65b9\u6cd5\uff08\u6bd4\u5982\u4e0a\u4f20\u8fdb\u5ea6\u53cd\u9988\uff0c\u4e0a\u4f20\u5b8c\u6210\u540e\u7684\u63d0\u793a\u7b49\uff09<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import UIKit\nimport MobileCoreServices\n \nclass UploadManager: NSObject, URLSessionDelegate, URLSessionTaskDelegate,\nURLSessionDataDelegate {\n     \n    \/\/\u5355\u4f8b\u6a21\u5f0f\n    static var shared = UploadManager()\n     \n    \/\/\u4e0a\u4f20\u8fdb\u5ea6\u56de\u8c03\n    var onProgress: ((Float) -> ())?\n     \n    \/\/background session\n    lazy var session:URLSession = {\n        \/\/\u53ea\u6267\u884c\u4e00\u6b21\n        let config = URLSessionConfiguration.background(withIdentifier:\n            \"background-session\")\n        let currentSession = URLSession(configuration: config, delegate: self,\n                                        delegateQueue: nil)\n        return currentSession\n    }()\n     \n    \/\/\u4e0a\u4f20\u4ee3\u7406\u65b9\u6cd5\uff0c\u76d1\u542c\u4e0a\u4f20\u8fdb\u5ea6\n    func urlSession(_ session: URLSession, task: URLSessionTask,\n                    didSendBodyData bytesSent: Int64, totalBytesSent: Int64,\n                    totalBytesExpectedToSend: Int64) {\n        \/\/\u83b7\u53d6\u8fdb\u5ea6\n        let written = (Float)(totalBytesSent)\n        let total = (Float)(totalBytesExpectedToSend)\n        let pro = written\/total\n        if let onProgress = onProgress {\n            onProgress(pro)\n        }\n    }\n     \n    \/\/\u4e0a\u4f20\u4ee3\u7406\u65b9\u6cd5\uff0c\u4f20\u8f93\u5b8c\u6bd5\u540e\u670d\u52a1\u7aef\u8fd4\u56de\u7ed3\u679c\n    func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {\n        let str = String(data: data, encoding: String.Encoding.utf8)\n        print(\"\u670d\u52a1\u7aef\u8fd4\u56de\u7ed3\u679c\uff1a\\(str!)\")\n    }\n     \n    \/\/\u4e0a\u4f20\u4ee3\u7406\u65b9\u6cd5\uff0c\u4e0a\u4f20\u7ed3\u675f\n    func urlSession(_ session: URLSession, task: URLSessionTask,\n                    didCompleteWithError error: Error?) {\n        print(\"\u4e0a\u4f20\u7ed3\u675f!\")\n    }\n     \n    \/\/session\u5b8c\u6210\u4e8b\u4ef6\n    func urlSessionDidFinishEvents(forBackgroundURLSession session: URLSession) {\n        \/\/\u4e3b\u7ebf\u7a0b\u8c03\u7528\n        DispatchQueue.main.async {\n            if let appDelegate = UIApplication.shared.delegate as? AppDelegate,\n                let completionHandler = appDelegate.backgroundSessionCompletionHandler {\n                appDelegate.backgroundSessionCompletionHandler = nil\n                \/\/\u8c03\u7528\u6b64\u65b9\u6cd5\u544a\u8bc9\u64cd\u4f5c\u7cfb\u7edf\uff0c\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u7684\u91cd\u65b0suspend\u4f60\u7684app\n                completionHandler()\n            }\n        }\n    }\n     \n    \/\/\u521b\u5efa\u8bf7\u6c42\n    static func createRequest(url: URL,\n                              parameters: [String: String]?,\n                              files: [(name:String, path:String)]) -> URLRequest{\n        \/\/\u5206\u9694\u7ebf\n        let boundary = \"Boundary-\\(UUID().uuidString)\"\n         \n        \/\/\u4e0a\u4f20\u5730\u5740\n        var request = URLRequest(url: url)\n        \/\/\u8bf7\u6c42\u7c7b\u578b\u4e3aPOST\n        request.httpMethod = \"POST\"\n        request.setValue(\"multipart\/form-data; boundary=\\(boundary)\",\n            forHTTPHeaderField: \"Content-Type\")\n         \n        \/\/\u521b\u5efa\u8868\u5355body\n        request.httpBody = try! createBody(with: parameters, files: files, boundary: boundary)\n        return request\n    }\n     \n    \/\/\u521b\u5efa\u8868\u5355body\n    static func createBody(with parameters: [String: String]?,\n                           files: [(name:String, path:String)],\n                           boundary: String) throws -> Data {\n        var body = Data()\n         \n        \/\/\u6dfb\u52a0\u666e\u901a\u53c2\u6570\u6570\u636e\n        if parameters != nil {\n            for (key, value) in parameters! {\n                \/\/ \u6570\u636e\u4e4b\u524d\u8981\u7528 --\u5206\u9694\u7ebf \u6765\u9694\u5f00 \uff0c\u5426\u5219\u540e\u53f0\u4f1a\u89e3\u6790\u5931\u8d25\n                body.append(\"--\\(boundary)\\r\\n\")\n                body.append(\"Content-Disposition: form-data; name=\\\"\\(key)\\\"\\r\\n\\r\\n\")\n                body.append(\"\\(value)\\r\\n\")\n            }\n        }\n         \n        \/\/\u6dfb\u52a0\u6587\u4ef6\u6570\u636e\n        for file in files {\n            let url = URL(fileURLWithPath: file.path)\n            let filename = url.lastPathComponent\n            let data = try Data(contentsOf: url)\n            let mimetype = mimeType(pathExtension: url.pathExtension)\n             \n            \/\/ \u6570\u636e\u4e4b\u524d\u8981\u7528 --\u5206\u9694\u7ebf \u6765\u9694\u5f00 \uff0c\u5426\u5219\u540e\u53f0\u4f1a\u89e3\u6790\u5931\u8d25\n            body.append(\"--\\(boundary)\\r\\n\")\n            body.append(\"Content-Disposition: form-data; \"\n                + \"name=\\\"\\(file.name)\\\"; filename=\\\"\\(filename)\\\"\\r\\n\")\n            body.append(\"Content-Type: \\(mimetype)\\r\\n\\r\\n\") \/\/\u6587\u4ef6\u7c7b\u578b\n            body.append(data) \/\/\u6587\u4ef6\u4e3b\u4f53\n            body.append(\"\\r\\n\") \/\/\u4f7f\u7528\\r\\n\u6765\u8868\u793a\u8fd9\u4e2a\u8fd9\u4e2a\u503c\u7684\u7ed3\u675f\u7b26\n        }\n         \n        \/\/ --\u5206\u9694\u7ebf-- \u4e3a\u6574\u4e2a\u8868\u5355\u7684\u7ed3\u675f\u7b26\n        body.append(\"--\\(boundary)--\\r\\n\")\n        return body\n    }\n     \n    \/\/\u6839\u636e\u540e\u7f00\u83b7\u53d6\u5bf9\u5e94\u7684Mime-Type\n    static func mimeType(pathExtension: String) -> String {\n        if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,\n                                                           pathExtension as NSString,\n                                                           nil)?.takeRetainedValue() {\n            if let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?\n                .takeRetainedValue() {\n                return mimetype as String\n            }\n        }\n        \/\/\u6587\u4ef6\u8d44\u6e90\u7c7b\u578b\u5982\u679c\u4e0d\u77e5\u9053\uff0c\u4f20\u4e07\u80fd\u7c7b\u578bapplication\/octet-stream\uff0c\u670d\u52a1\u5668\u4f1a\u81ea\u52a8\u89e3\u6790\u6587\u4ef6\u7c7b\n        return \"application\/octet-stream\"\n    }\n}\n \n\/\/\u6269\u5c55Data\nextension Data {\n    \/\/\u589e\u52a0\u76f4\u63a5\u6dfb\u52a0String\u6570\u636e\u7684\u65b9\u6cd5\n    mutating func append(_ string: String, using encoding: String.Encoding = .utf8) {\n        if let data = string.data(using: encoding) {\n            append(data)\n        }\n    }\n}<\/pre>\n\n\n\n<p>\uff082\uff09\u540c\u65f6<strong>&nbsp;AppDelegate.swift&nbsp;<\/strong>\u4e2d\u8981\u505a\u5982\u4e0b\u4fee\u6539\uff1a<\/p>\n\n\n\n<ul><li>\u540e\u53f0\u4e0a\u4f20\u5b8c\u6bd5\u540e\u4f1a\u8c03\u7528&nbsp;<strong>handleEventsForBackgroundURLSession&nbsp;<\/strong>\u65b9\u6cd5\u3002<\/li><li>\u6211\u4eec\u5728\u6b64\u7528\u63d0\u4f9b\u7684&nbsp;<strong>identifier&nbsp;<\/strong>\u521b\u5efa\u65b0\u7684&nbsp;<strong>URLSessionConfiguration&nbsp;<\/strong>\u548c&nbsp;<strong>URLSession&nbsp;<\/strong>\u5bf9\u8c61\u3002<\/li><li>\u7136\u540e\u5c06\u65b0\u7684&nbsp;<strong>session&nbsp;<\/strong>\u5bf9\u8c61\u91cd\u65b0\u8fde\u63a5\u5230\u5148\u524d\u7684\u4efb\u52a1\uff0c\u5e76\u8c03\u7528\u76f8\u5e94\u7684&nbsp;<strong>delegate<\/strong>\u3002<\/li><\/ul>\n\n\n\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u5728\u524d\u9762&nbsp;<strong>UploadManager&nbsp;<\/strong>\u91cc\u7684&nbsp;<strong>urlSessionDidFinishEvents()&nbsp;<\/strong>\u8fd9\u4e2a&nbsp;<strong>session&nbsp;<\/strong>\u4ee3\u7406\u65b9\u6cd5\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u8981\u5728\u4e3b\u7ebf\u7a0b\u91cc\u8c03\u7528&nbsp;<strong>AppDelegate&nbsp;<\/strong>\u91cc\u4fdd\u5b58\u7684&nbsp;<strong>completionHandler<\/strong>\u3002\u8fd9\u6837\u5c31\u4f1a\u544a\u8bc9\u64cd\u4f5c\u7cfb\u7edf\uff0c\u73b0\u5728\u53ef\u4ee5\u5b89\u5168\u7684\u91cd\u65b0&nbsp;<strong>suspend&nbsp;<\/strong>\u6211\u4eec\u7684&nbsp;<strong>app&nbsp;<\/strong>\u4e86\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import UIKit\n \n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n     \n    \/\/\u7528\u4e8e\u4fdd\u5b58\u540e\u53f0\u4e0a\u4f20\u7684completionHandler\n    var backgroundSessionCompletionHandler: (() -> Void)?\n \n    var window: UIWindow?\n     \n    \/\/\u540e\u53f0\u4e0a\u4f20\u5b8c\u6bd5\u540e\u4f1a\u8c03\u7528\uff08\u6211\u4eec\u5c06\u5176\u4ea4\u7531\u4e0a\u4f20\u5de5\u5177\u7c7b\u505a\u540e\u7eed\u5904\u7406\uff09\n    func application(_ application: UIApplication,\n                     handleEventsForBackgroundURLSession identifier: String,\n                     completionHandler: @escaping () -> Void) {\n \n        \/\/\u7528\u4e8e\u4fdd\u5b58\u540e\u53f0\u4e0a\u4f20\u7684completionHandler\n        backgroundSessionCompletionHandler = completionHandler\n         \n        \/\/\u521b\u5efaupload session\n        let configuration = URLSessionConfiguration.background(withIdentifier: identifier)\n        let uploadSession = URLSession(configuration: configuration,\n                                          delegate: UploadManager.shared,\n                                          delegateQueue: nil)\n         \n        \/\/\u6307\u5b9aupload session\n        UploadManager.shared.session = uploadSession\n    }\n \n    func application(_ application: UIApplication, didFinishLaunchingWithOptions\n        launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {\n        return true\n    }\n \n    func applicationWillResignActive(_ application: UIApplication) {\n    }\n \n    func applicationDidEnterBackground(_ application: UIApplication) {\n    }\n \n    func applicationWillEnterForeground(_ application: UIApplication) {\n    }\n \n    func applicationDidBecomeActive(_ application: UIApplication) {\n    }\n \n    func applicationWillTerminate(_ application: UIApplication) {\n    }\n}<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">3\uff0c\u4f7f\u7528\u6837\u4f8b<\/h5>\n\n\n\n<p>\uff081\uff09\u5ba2\u6237\u7aef\u4ee3\u7801\uff08<strong>ViewController.swift<\/strong>\uff09<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import UIKit\n \nclass ViewController: UIViewController {\n     \n    @IBAction func startUpload(_ sender: Any) {\n         \n        \/\/\u4f20\u9012\u7684\u53c2\u6570\n        let parameters = [\n            \"value1\": \"hangge.com\",\n            \"value2\": \"1234\"\n        ]\n         \n        \/\/\u4f20\u9012\u7684\u6587\u4ef6\n        let files = [\n            (\n                name: \"file1\",\n                path:Bundle.main.path(forResource: \"test1\", ofType: \"zip\")!\n            ),\n            (\n                name: \"file2\",\n                path:Bundle.main.path(forResource: \"test3\", ofType: \"zip\")!\n            )\n        ]\n         \n        \/\/\u4e0a\u4f20\u5730\u5740\n        let url = URL(string: \"http:\/\/www.hangge.com\/upload.php\")!\n         \n        \/\/\u521b\u5efarequest\n        let request = UploadManager.createRequest(url: url, parameters: parameters, files: files)\n         \n        \/\/\u521b\u5efa\u4e0a\u4f20\u4efb\u52a1\n        let uploadTask = UploadManager.shared.session.uploadTask(withStreamedRequest: request)\n         \n        \/\/\u4f7f\u7528resume\u65b9\u6cd5\u542f\u52a8\u4efb\u52a1\n        uploadTask.resume()\n         \n        \/\/\u5b9e\u65f6\u6253\u5370\u51fa\u4e0a\u4f20\u8fdb\u5ea6\n        UploadManager.shared.onProgress = { (progress) in\n            OperationQueue.main.addOperation {\n                print(\"\u4e0a\u4f20\u8fdb\u5ea6\uff1a\\(progress)\")\n            }\n        }\n    }\n}<\/pre>\n\n\n\n<p>\uff082\uff09\u670d\u52a1\u7aef\u4ee3\u7801\uff08<strong>upload.php<\/strong>\uff09\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?\n$value1 = $_POST[\"value1\"];\n$value2 = $_POST[\"value2\"];\n  \nmove_uploaded_file($_FILES[\"file1\"][\"tmp_name\"],\n    $_SERVER[\"DOCUMENT_ROOT\"].\"\/uploadFiles\/\" . $_FILES[\"file1\"][\"name\"]);\n \nmove_uploaded_file($_FILES[\"file2\"][\"tmp_name\"],\n    $_SERVER[\"DOCUMENT_ROOT\"].\"\/uploadFiles\/\" . $_FILES[\"file2\"][\"name\"]);\n \necho \"\\r\\n\u4e24\u4e2a\u53c2\u6570\u4e3a\uff1a\".$value1.\"\uff0c\".$value2;\necho \"\\r\\n\u4e24\u4e2a\u6587\u4ef6\u4e3a\uff1a\". $_FILES[\"file1\"][\"name\"].\"\uff0c\".$_FILES[\"file2\"][\"name\"];\n?><\/pre>\n\n\n\n<p>\uff083\uff09\u8fd0\u884c\u6548\u679c\uff1a<\/p>\n\n\n\n<ul><li>\u70b9\u51fb\u754c\u9762\u4e0a\u7684\u6309\u94ae\u5f00\u59cb\u4e0a\u4f20\uff0c\u53ef\u4ee5\u770b\u5230\u63a7\u5236\u53f0\u4e2d\u4e0d\u65ad\u5730\u6253\u5370\u51fa\u4e0a\u4f20\u8fdb\u5ea6\u3002<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/06\/image-22-1024x339.png\" alt=\"\" class=\"wp-image-3125\" width=\"543\" height=\"180\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22-1024x339.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22-300x99.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22-768x254.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22-830x275.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22-230x76.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22-350x116.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22-480x159.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-22.png 1340w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/figure><\/div>\n\n\n\n<ul><li>\u6309\u4e0b&nbsp;<strong>home&nbsp;<\/strong>\u952e\u5c06\u5e94\u7528\u9000\u5230\u540e\u53f0\u3002\u867d\u7136\u63a7\u5236\u53f0\u4e0d\u518d\u7ee7\u7eed\u6253\u5370\u4e0a\u4f20\u8fdb\u5ea6\uff0c\u4f46\u4e8b\u5b9e\u4e0a\u540e\u53f0\u4ecd\u5728\u7ee7\u7eed\u4e0a\u4f20\u6570\u636e\uff0c\u5e76\u5728\u4e0a\u4f20\u5b8c\u6bd5\u540e\u81ea\u52a8\u8c03\u7528\u76f8\u5173\u65b9\u6cd5\u3002<\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/06\/image-23-1024x437.png\" alt=\"\" class=\"wp-image-3126\" width=\"555\" height=\"237\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23-1024x437.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23-300x128.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23-768x328.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23-830x354.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23-230x98.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23-350x149.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23-480x205.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/06\/image-23.png 1124w\" sizes=\"(max-width: 555px) 100vw, 555px\" \/><\/figure><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">\u6ce8\u610ftimeoutIntervalForResource\u548ctimeoutIntervalForRequest\u7684\u533a\u522b<\/h5>\n\n\n\n<p>timeoutIntervalForResource\u662f\u8868\u793a\u6570\u636e\u6ca1\u6709\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u91cc\u9762\u52a0\u8f7d\u5b8c\uff0c\u9ed8\u8ba4\u503c\u662f7\u5929\u3002<\/p>\n\n\n\n<p>timeoutIntervalForRequest\u662f\u8868\u793a\u5728\u4e0b\u8f7d\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u67d0\u6bb5\u65f6\u95f4\u4e4b\u5185\u4e00\u76f4\u90fd\u6ca1\u6709\u63a5\u6536\u5230\u6570\u636e\uff0c\u90a3\u4e48\u5c31\u8ba4\u4e3a\u8d85\u65f6\u3002<\/p>\n\n\n\n<p>\u4e3e\u4e2a\u4f8b\u5b50\u5c31\u662f\uff0c\u5982\u679c\u4f60\u8981\u4e0b\u4e00\u4e2a10G\u7684\u6570\u636e\uff0ctimeoutIntervalForResource\u8bbe\u7f6e\u62107\u5929\u7684\u8bdd\uff0c\u4f60\u7684\u7f51\u901f\u7279\u522b\u6162\uff1a0.1k\/s\uff0c7\u5929\u90fd\u6ca1\u4e0b\u8f7d\u5b8c\uff0c\u90a3\u5c31\u8d85\u65f6\u4e86\u3002\u867d\u7136\u6574\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u4e00\u76f4\u5728\u6e90\u6e90\u4e0d\u65ad\u5730\u4e0b\u8f7d\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u8981\u4e0b\u4e00\u4e2a10G\u7684\u6570\u636e\uff0ctimeoutIntervalForRequest\u8bbe\u7f6e\u4e3a20\u79d2\u7684\u8bdd\uff0c\u4e0b\u7684\u8fc7\u7a0b\u4e2d\u6709\u8d85\u8fc720s\u7684\u65f6\u95f4\u6bb5\u5e76\u6ca1\u6709\u6570\u636e\u8fc7\u6765\uff0c\u90a3\u4e48\u8fd9\u65f6\u5019\u5c31\u4e5f\u7b97\u8d85\u65f6\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> let config = URLSessionConfiguration.background(withIdentifier: (\"\\(Date().timeIntervalSince1970)_\\(partInfoId)\"))\n        config.timeoutIntervalForRequest = 30\n        config.timeoutIntervalForResource = 300\n        \n        let session = URLSession(configuration: config, delegate: appDelegateComm, delegateQueue: OperationQueue.main)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp; \u6211\u4e4b\u524d\u5199\u8fc7\u4e00\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u5982\u4f55\u5b9e\u73b0\u5927\u6587\u4ef6\u7684\u540e\u53f0\u4e0b\u8f7d\uff08\u70b9\u51fb\u67e5\u770b\uff09\uff0c\u672c\u6587\u63a5\u7740\u6f14\u793a\u540e\u53f0\u4e0a\u4f20\u529f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3124"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3124"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3124\/revisions"}],"predecessor-version":[{"id":3366,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3124\/revisions\/3366"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}