{"id":8061,"date":"2022-09-21T16:57:16","date_gmt":"2022-09-21T08:57:16","guid":{"rendered":"https:\/\/www.yimenapp.com\/kb-yimen\/?p=8061"},"modified":"2022-09-21T16:57:17","modified_gmt":"2022-09-21T08:57:17","slug":"app%e5%bc%80%e5%8f%91%e5%bd%95%e9%9f%b3%e5%8a%9f%e8%83%bd-upload-%e4%b8%8a%e4%bc%a0%e5%bd%95%e9%9f%b3","status":"publish","type":"post","link":"https:\/\/www.yimenapp.com\/kb-yimen\/8061\/","title":{"rendered":"APP\u5f00\u53d1\u5f55\u97f3\u529f\u80fd  upload\u00a0\u4e0a\u4f20\u5f55\u97f3"},"content":{"rendered":"\n<figure id=\"pid16585\" class=\"wp-block-table\"><table><tbody><tr><td>\u7528\u505a\u7f51\u9875\u7684\u6280\u672f\u505a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.yimenapp.com\/\" target=\"_blank\">APP<\/a>\uff01<br><span class=\"wpcom_keyword_link\"><a href=\"https:\/\/www.yimenapp.com\" title=\"\u5f00\u53d1APP\u4ece\u4e00\u95e8\u5f00\u59cb\">\u4e00\u95e8<\/a><\/span>\u63d0\u4f9b\u6807\u51c6\u5316\u7684<strong>jsbridge-mini.js\u5e93<\/strong>\uff0c\u60a8\u53ea\u9700\u8981\u5728\u9875\u9762<strong>\u5f15\u7528<\/strong>\u5e76<strong>\u6267\u884c<\/strong>JS\u5373\u53ef\u5b9e\u73b0\u5404\u79cd<strong>\u539f\u751fAPP\u3001\u539f\u751fPC<\/strong>\u7684\u529f\u80fd\u80fd\u529b\u3002<br><br><strong>==================APP\u7aef==================<\/strong><br><strong>\u3010APP\u7aef\u3011\uff08\u5b89\u5353\u7248&amp;\u82f9\u679c\u7248\uff09<\/strong>\u76ee\u524d\u63d0\u4f9b200+\u539f\u751f\u529f\u80fd\uff0c2000+JS\u6620\u5c04\u63a5\u53e3\uff0c\u7528\u505a\u7f51\u7ad9\u7684\u6280\u672f\u5373\u53ef\u5b9e\u73b0\u5404\u79cd\u539f\u751fAPP\u80fd\u529b\u3001APP demo\u5730\u5740<a rel=\"noreferrer noopener\" href=\"https:\/\/www.yimenapp.com\/doc\/demo.cshtml\" target=\"_blank\">https:\/\/www.yimenapp.com\/doc\/demo.cshtml<\/a>\u4e0b\u8f7d\u6559\u7a0b\uff1a<br>\u2666\u00a0<strong>JS-SDK<\/strong>\u00a0\u5f15\u7528\u65b9\u5f0f\uff1a<br>\u2666 \u666e\u901a\u7f51\u9875 script \u65b9\u5f0f\u52a0\u8f7d\uff1a\u4e0b\u8f7d\u6700\u65b0\u7248\uff0c\u8bf7\u5728\u9875\u9762\u4e0a\u8c03\u7528 jsBridge \u63a5\u53e3\u4e4b\u524d\u5f15\u7528 jsbridge-mini.js \u5e93\uff1b<br>\u2666 js module \u65b9\u5f0f\u5f15\u7528\uff1anpm install ym-jsbridge\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.npmjs.com\/package\/ym-jsbridge\" target=\"_blank\">\u5177\u4f53\u8bf7\u53c2\u8003 npm package<\/a><\/td><\/tr><\/tbody><\/table><figcaption>\u4e00\u95e8APP\u5f00\u53d1\u5e73\u53f0\u901a\u7528JS<\/figcaption><\/figure>\n\n\n\n<p>upload\u00a0\u4e0a\u4f20\u5f55\u97f3<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/\u4e0a\u4f20\u6700\u8fd1\u4e00\u6b21\u7684\u5f55\u97f3\n\/\/POST\uff08multipart\/form-data \u7f16\u7801\uff09\u65b9\u5f0f\u4e0a\u4f20\u6700\u65b0\u5f55\u97f3\u6587\u4ef6\u5230\u6307\u5b9a\u7684\u5730\u5740\njsBridge.audioRecorder.<em>upload<\/em>({\n  \/\/\u5fc5\u987b\uff0c\u5b57\u7b26\u4e32\u7c7b\u578b\uff0cPOST \u65b9\u5f0f\u63a5\u6536\u5f55\u97f3\u6587\u4ef6\u7684\u94fe\u63a5\u5730\u5740\n  \/\/\u5982\u9700\u9274\u6743\uff0c\u8bf7\u5c06\u9274\u6743\u53c2\u6570\u653e\u5728\u6b64 url \u4e0a\uff0c\u53c2\u6570\u9700 urlEncode \u7f16\u7801\n  url  : \"https:\/\/...\",\n  \/\/\u53ef\u9009\uff0c\u5b57\u7b26\u4e32\u7c7b\u578b\uff0cform-data \u8868\u5355\u9879\u540d\u79f0\uff0c\u9ed8\u8ba4 file\n  \/\/\u5728\u670d\u52a1\u5668\u4e0a\u7528\u7c7b\u4f3c Request.Files[\"file\"] \u65b9\u5f0f\u83b7\u53d6\u6570\u636e\n  name : \"file\"\n}, function(succ, data) {\n  show({\n    succ: succ,\n    data: data\n  });\n});\n\n\/**\n\u56de\u8c03\u4e8b\u4ef6\uff08\u9700\u8c03\u7528 setListener \u76d1\u542c\uff09\nevent\n  20 \/\/\u4e0a\u4f20\u8fdb\u5ea6\n     data: {\n       uploaded :, \/\/\u6570\u5b57\u7c7b\u578b\uff0c\u5df2\u4e0a\u4f20\u5b57\u8282\u6570(byte)\n       total    :  \/\/\u6570\u5b57\u7c7b\u578b\uff0c\u603b\u5b57\u8282\u6570(byte)\n     }\n  21 \/\/\u4e0a\u4f20\u7ed3\u675f\n     data: {\n        success :, \/\/\u5e03\u5c14\u7c7b\u578b\uff0c\u662f\u5426\u4e0a\u4f20\u6210\u529f\n        message :, \/\/\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u672a\u6210\u529f\u65f6\u7684\u9519\u8bef\u8bf4\u660e\n        response : \/\/\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u670d\u52a1\u5668\u7aef\u8fd4\u56de\u7684 Reponse \u5b57\u7b26\u4e32\n     }\n**\/<\/pre>\n\n\n\n<p>A\u6807\u7b7e\u6267\u884cJS\u793a\u4f8b\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;a href=\"javascript:void(0)\" onclick=\"zhixing()\">\u6267\u884c&lt;\/a> \n&lt;!-- \u5199\u5165\u4e00\u4e2aA\u6807\u7b7ehref\u503c\u4e3a\"javascript:void(0)\"\uff0c\u5b9a\u4e49\u70b9\u51fb\u4e8b\u4ef6onclick\uff1b-->\n&lt;script src=\"\u60a8\u7684\u670d\u52a1\u5668URL\/jsbridge-mini.js\">&lt;\/script>\n&lt;!-- \u5728\u60a8\u7684\u670d\u52a1\u5668\u5f15\u5165\u4e00\u95e8JS\u5730\u5740\uff0c\u8bf7\u4e0b\u8f7djsbridge-mini.js\u4e0a\u4f20\u60a8\u81ea\u5df1\u7684\u670d\u52a1\u5668\u83b7\u53d6\u94fe\u63a5\uff1b-->\n&lt;script type=\"text\/javascript\">\nfunction zhixing() {\n\n\n&lt;!--\u8fd9\u91cc\u53ef\u4ee5\u76f4\u63a5\u590d\u5236JS\u6838\u5fc3\u4ee3\u7801\u5230\u6b64{}\u62ec\u53f7\u5185-->\n\/\/\u4e0a\u4f20\u6700\u8fd1\u4e00\u6b21\u7684\u5f55\u97f3\r\n\/\/POST\uff08multipart\/form-data \u7f16\u7801\uff09\u65b9\u5f0f\u4e0a\u4f20\u6700\u65b0\u5f55\u97f3\u6587\u4ef6\u5230\u6307\u5b9a\u7684\u5730\u5740\r\njsBridge.audioRecorder.upload({\r\n  \/\/\u5fc5\u987b\uff0c\u5b57\u7b26\u4e32\u7c7b\u578b\uff0cPOST \u65b9\u5f0f\u63a5\u6536\u5f55\u97f3\u6587\u4ef6\u7684\u94fe\u63a5\u5730\u5740\r\n  \/\/\u5982\u9700\u9274\u6743\uff0c\u8bf7\u5c06\u9274\u6743\u53c2\u6570\u653e\u5728\u6b64 url \u4e0a\uff0c\u53c2\u6570\u9700 urlEncode \u7f16\u7801\r\n  url  : \"https:\/\/...\",\r\n  \/\/\u53ef\u9009\uff0c\u5b57\u7b26\u4e32\u7c7b\u578b\uff0cform-data \u8868\u5355\u9879\u540d\u79f0\uff0c\u9ed8\u8ba4 file\r\n  \/\/\u5728\u670d\u52a1\u5668\u4e0a\u7528\u7c7b\u4f3c Request.Files&#91;\"file\"] \u65b9\u5f0f\u83b7\u53d6\u6570\u636e\r\n  name : \"file\"\r\n}, function(succ, data) {\r\n  show({\r\n    succ: succ,\r\n    data: data\r\n  });\r\n});\r\n\r\n\/**\r\n\u56de\u8c03\u4e8b\u4ef6\uff08\u9700\u8c03\u7528 setListener \u76d1\u542c\uff09\r\nevent\r\n  20 \/\/\u4e0a\u4f20\u8fdb\u5ea6\r\n     data: {\r\n       uploaded :, \/\/\u6570\u5b57\u7c7b\u578b\uff0c\u5df2\u4e0a\u4f20\u5b57\u8282\u6570(byte)\r\n       total    :  \/\/\u6570\u5b57\u7c7b\u578b\uff0c\u603b\u5b57\u8282\u6570(byte)\r\n     }\r\n  21 \/\/\u4e0a\u4f20\u7ed3\u675f\r\n     data: {\r\n        success :, \/\/\u5e03\u5c14\u7c7b\u578b\uff0c\u662f\u5426\u4e0a\u4f20\u6210\u529f\r\n        message :, \/\/\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u672a\u6210\u529f\u65f6\u7684\u9519\u8bef\u8bf4\u660e\r\n        response : \/\/\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u670d\u52a1\u5668\u7aef\u8fd4\u56de\u7684 Reponse \u5b57\u7b26\u4e32\r\n     }\r\n**\/\n\n}\n&lt;\/script>\n&lt;!--\u6267\u884c\u6838\u5fc3\u4ee3\u7801\uff1b\n\/\/\u5982\u679c\u9700\u8981\u8fdb\u5165\u9875\u9762\u5c31\u6267\u884c\uff0c\u53bb\u6389\u70b9\u51fb\u4e8b\u4ef6\u5373\u53ef\uff1b--><\/code><\/pre>\n\n\n\n<p>\u6309\u94ae\u6267\u884cJS\u793a\u4f8b\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;button onclick=\"zhixing()\" >\u6267\u884c&lt;\/button>\n&lt;!-- \/\/\u5199\u4e00\u4e2a\u6309\u94ae\uff0c\u5b9a\u4e49\u70b9\u51fb\u6267\u884c\u4e8b\u4ef6\uff1b -->\n&lt;script src=\"\u60a8\u7684\u670d\u52a1\u5668URL\/jsbridge-mini.js\">&lt;\/script>\n&lt;!-- \/\/\u5728\u60a8\u7684\u670d\u52a1\u5668\u5f15\u5165\u4e00\u95e8JS\u5730\u5740\uff0c\u8bf7\u4e0b\u8f7djsbridge-mini.js\u4e0a\u4f20\u60a8\u81ea\u5df1\u7684\u670d\u52a1\u5668\u83b7\u53d6\u94fe\u63a5\uff1b -->\n&lt;script type=\"text\/javascript\">\nfunction zhixing() {\n\n\n&lt;!--\u8fd9\u91cc\u53ef\u4ee5\u76f4\u63a5\u590d\u5236JS\u6838\u5fc3\u4ee3\u7801\u5230\u6b64{}\u62ec\u53f7\u5185-->\n\/\/\u4e0a\u4f20\u6700\u8fd1\u4e00\u6b21\u7684\u5f55\u97f3\r\n\/\/POST\uff08multipart\/form-data \u7f16\u7801\uff09\u65b9\u5f0f\u4e0a\u4f20\u6700\u65b0\u5f55\u97f3\u6587\u4ef6\u5230\u6307\u5b9a\u7684\u5730\u5740\r\njsBridge.audioRecorder.upload({\r\n  \/\/\u5fc5\u987b\uff0c\u5b57\u7b26\u4e32\u7c7b\u578b\uff0cPOST \u65b9\u5f0f\u63a5\u6536\u5f55\u97f3\u6587\u4ef6\u7684\u94fe\u63a5\u5730\u5740\r\n  \/\/\u5982\u9700\u9274\u6743\uff0c\u8bf7\u5c06\u9274\u6743\u53c2\u6570\u653e\u5728\u6b64 url \u4e0a\uff0c\u53c2\u6570\u9700 urlEncode \u7f16\u7801\r\n  url  : \"https:\/\/...\",\r\n  \/\/\u53ef\u9009\uff0c\u5b57\u7b26\u4e32\u7c7b\u578b\uff0cform-data \u8868\u5355\u9879\u540d\u79f0\uff0c\u9ed8\u8ba4 file\r\n  \/\/\u5728\u670d\u52a1\u5668\u4e0a\u7528\u7c7b\u4f3c Request.Files&#91;\"file\"] \u65b9\u5f0f\u83b7\u53d6\u6570\u636e\r\n  name : \"file\"\r\n}, function(succ, data) {\r\n  show({\r\n    succ: succ,\r\n    data: data\r\n  });\r\n});\r\n\r\n\/**\r\n\u56de\u8c03\u4e8b\u4ef6\uff08\u9700\u8c03\u7528 setListener \u76d1\u542c\uff09\r\nevent\r\n  20 \/\/\u4e0a\u4f20\u8fdb\u5ea6\r\n     data: {\r\n       uploaded :, \/\/\u6570\u5b57\u7c7b\u578b\uff0c\u5df2\u4e0a\u4f20\u5b57\u8282\u6570(byte)\r\n       total    :  \/\/\u6570\u5b57\u7c7b\u578b\uff0c\u603b\u5b57\u8282\u6570(byte)\r\n     }\r\n  21 \/\/\u4e0a\u4f20\u7ed3\u675f\r\n     data: {\r\n        success :, \/\/\u5e03\u5c14\u7c7b\u578b\uff0c\u662f\u5426\u4e0a\u4f20\u6210\u529f\r\n        message :, \/\/\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u672a\u6210\u529f\u65f6\u7684\u9519\u8bef\u8bf4\u660e\r\n        response : \/\/\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u670d\u52a1\u5668\u7aef\u8fd4\u56de\u7684 Reponse \u5b57\u7b26\u4e32\r\n     }\r\n**\/\n\n}\n&lt;\/script>\n&lt;!-- \/\/\u6267\u884c\u6838\u5fc3\u4ee3\u7801\uff1b\n\/\/\u5982\u679c\u9700\u8981\u8fdb\u5165\u9875\u9762\u5c31\u6267\u884c\uff0c\u53bb\u6389\u70b9\u51fb\u4e8b\u4ef6\u5373\u53ef\uff1b --><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/POST\uff08multipart\/form-data \u7f16\u7801\uff09\u65b9\u5f0f\u4e0a\u4f20\u6700\u65b0\u5f55\u97f3\u6587\u4ef6\u5230\u6307\u5b9a\u7684\u5730\u5740<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[702],"tags":[2669,2668,2671,2681,2677,2672],"special":[],"attr":[],"class_list":{"0":"post-8061","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-app87","7":"tag-app","13":"entry"},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/8061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/comments?post=8061"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/8061\/revisions"}],"predecessor-version":[{"id":8062,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/8061\/revisions\/8062"}],"wp:attachment":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/media?parent=8061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/categories?post=8061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/tags?post=8061"},{"taxonomy":"special","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/special?post=8061"},{"taxonomy":"attr","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/attr?post=8061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}