{"id":554,"date":"2019-05-01T10:24:17","date_gmt":"2019-05-01T01:24:17","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2019\/05\/01\/xamarinforms_multipartpost\/"},"modified":"2019-05-01T10:24:17","modified_gmt":"2019-05-01T01:24:17","slug":"xamarinforms_multipartpost","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2019\/05\/01\/xamarinforms_multipartpost\/","title":{"rendered":"Xamarin.Forms \u30d5\u30a1\u30a4\u30eb\u3092Multipart\u3067Post\u3059\u308b"},"content":{"rendered":"<p><a href=\"https:\/\/www.amazon.co.jp\/Effective-C-6-0-7-0-BillWagner-ebook\/dp\/B07F9R3X87\/ref=as_li_ss_il?__mk_ja_JP=%E3%82%AB%E3%82%BF%E3%82%AB%E3%83%8A&amp;keywords=C#&amp;qid=1556673684&amp;s=gateway&amp;sr=8-8&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=87f091b4a8635e707e8ccbf35f575b7c\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=B07F9R3X87&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=li2&amp;o=9&amp;a=B07F9R3X87\" border=\"0\"><\/p>\n<ol>\n<li><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/06\/google_app_engine_java_standard_spring_boot\">Google App Engine Java Standard + Spring Boot \u74b0\u5883\u69cb\u7bc9<\/a>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/06\/google_app_engine_java_standard_spring_boot_thymeleaf\">Spring Boot\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3 Thymeleaf\u3092\u9069\u7528<\/a><\/p>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/06\/google_app_engine_java_spring_bootvuejs\">Spring Boot\u306bVue.js\u3092\u5229\u7528\u3059\u308b<\/a><\/p>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/20\/google_app_engine_java_spring_bootvuetifyajax\">Spring Boot\u306bVuetify\u5c0e\u5165\u304b\u3089\u30af\u30ed\u30b9\u30c9\u30e1\u30a4\u30f3Ajax\u901a\u4fe1<\/a><\/p>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/24\/google_app_engine_java_spring_bootvuetify_gae\">Spring Boot+Vuetify GAE\u3078\u30c7\u30d7\u30ed\u30a4\u3001\u52d5\u4f5c\u78ba\u8a8d<\/a><\/p>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/24\/visual_studio2019_xamarinformsios\">Xamarin.Forms\u30a2\u30d7\u30ea\u3092iOS\u7528\u306b\u30d3\u30eb\u30c9<\/a><\/p>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/28\/xamarinforms_http\">Xamarin.Forms \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u306e\u8868\u793a\u3068 Http\u901a\u4fe1<\/a><\/p>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/29\/google_app_engine_java_spring_bootvuetify_json\">Spring Boot+Vuetify \u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3068JSON\u3067\u7d50\u679c\u3092\u8fd4\u3059<\/a><\/p>\n<li>\n<p>Google <a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/30\/google_app_enginejavaspring_bootvuetifygoogle_cloud_vision_apiocr\">Google Cloud Vision \u3067OCR\u3002Vuetify\u304b\u3089SpringBoot\u7d4c\u7531\u3067\u547c\u3073\u51fa\u3057<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/05\/01\/xamarinforms\">Xamarin \u30d5\u30a1\u30a4\u30eb\u9078\u629e<\/a><\/p>\n<\/li>\n<\/ol>\n<h2>1.\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9<\/h2>\n<p><a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/04\/30\/google_app_enginejavaspring_bootvuetifygoogle_cloud_vision_apiocr\">GAE\u5074\u3067\u3001Google Cloud Vision API\u3092\u4f7f\u3063\u3066\u3001OCR\u3092\u5b9f\u884c\u3059\u308bAPI\u3092\u4f5c\u6210<\/a> \u3057\u3001<a href=\"https:\/\/www.typea.info\/blog\/index.php\/2019\/05\/01\/xamarinforms\">Xamarin\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u305f<\/a>\u306e\u3067\u3001API\u306b\u3001Multipart Post\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u9001\u4fe1\u3057\u3001OCR\u306e\u7d50\u679c\u3092\u5f97\u308b\u3002<\/p>\n<p><a title=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.net.webclient.uploadfile?redirectedfrom=MSDN&amp;view=netframework-4.8#System_Net_WebClient_UploadFile_System_String_System_String_\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.net.webclient.uploadfile?\">https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.net.webclient.uploadfile?<\/a><\/p>\n<p><a title=\"https:\/\/stackoverflow.com\/questions\/19954287\/how-to-upload-file-to-server-with-http-post-multipart-form-data\" href=\"https:\/\/stackoverflow.com\/questions\/19954287\/how-to-upload-file-to-server-with-http-post-multipart-form-data\">https:\/\/stackoverflow.com\/questions\/19954287\/how-to-upload-file-to-server-with-http-post-multipart-form-data<\/a><\/p>\n<p>\u3053\u306e\u8fba\u308a\u3092\u53c2\u8003\u306b\u3002<\/p>\n<p><pre class=\"prettyprint linenums\">private async void FilePick()\r\n{\r\n    var file = await CrossFilePicker.Current.PickFile();\r\n\r\n    if (file != null)\r\n    {\r\n        byte[] fileBytes = null;\r\n        using(MemoryStream ms = new MemoryStream()) {\r\n            byte[] buf = new byte[1024 * 16];\r\n            int read;\r\n            var inputStream = file.GetStream();\r\n            while ((read = inputStream.Read(buf,0,buf.Length)) &gt; 0)\r\n            {\r\n                ms.Write(buf, 0, read);\r\n            }\r\n\r\n            fileBytes = ms.ToArray();\r\n        }\r\n        if (fileBytes != null)\r\n        {\r\n            string uri = \"https:\/\/favophrase.com\/api\/upload-file\";\r\n\r\n            HttpClient httpClient = new HttpClient();\r\n            MultipartFormDataContent form = new MultipartFormDataContent();\r\n\r\n            form.Add(new StringContent(file.FileName), \"fileName\");\r\n\r\n            form.Add(new ByteArrayContent(fileBytes, 0, fileBytes.Length), \"file\", file.FilePath);\r\n            HttpResponseMessage response = await httpClient.PostAsync(uri, form);\r\n\r\n            response.EnsureSuccessStatusCode();\r\n            httpClient.Dispose();\r\n\r\n            string sd = response.Content.ReadAsStringAsync().Result;\r\n\r\n            await Page.DisplayAlert(\"Uploaded File.\", sd, \"OK\");\r\n        }\r\n    }\r\n}\r\n<\/pre>\n<h2>2.\u5b9f\u884c\u7d50\u679c<\/h2>\n<p>Android,iPhone,UWP \u306b\u3066\u3001\u305d\u308c\u305e\u308c\u3001\u30d5\u30a1\u30a4\u30eb\u9078\u629e\u304b\u3089\u3001\u30d5\u30a1\u30a4\u30eb\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3001OCR\u306e\u7d50\u679c\u3092\u8868\u793a\u3067\u304d\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Xamarin-File-upload_8478\/xamarin_fileupload_android.png\"><img loading=\"lazy\" decoding=\"async\" width=\"220\" height=\"409\" title=\"xamarin_fileupload_android\" style=\"display: inline; background-image: none;\" alt=\"xamarin_fileupload_android\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Xamarin-File-upload_8478\/xamarin_fileupload_android_thumb.png\" border=\"0\"><\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Xamarin-File-upload_8478\/xamarin_fileupload_ios.png\"><br \/><\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Xamarin-File-upload_8478\/xamarin_fileupload_ios.png\"><img loading=\"lazy\" decoding=\"async\" width=\"220\" height=\"470\" title=\"xamarin_fileupload_ios\" style=\"display: inline; background-image: none;\" alt=\"xamarin_fileupload_ios\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Xamarin-File-upload_8478\/xamarin_fileupload_ios_thumb.png\" border=\"0\"><\/a><\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Xamarin-File-upload_8478\/xamarin_fileupload_uwp.png\"><img loading=\"lazy\" decoding=\"async\" width=\"454\" height=\"356\" title=\"xamarin_fileupload_uwp\" style=\"display: inline; background-image: none;\" alt=\"xamarin_fileupload_uwp\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Xamarin-File-upload_8478\/xamarin_fileupload_uwp_thumb.png\" border=\"0\"><\/a><\/p>\n<p>\u3044\u3044\u611f\u3058\u3002<\/p>\n<p><a href=\"https:\/\/www.amazon.co.jp\/%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0Xamarin-%E4%B8%8A-Xamarin-Forms%E3%81%A8C-%E3%81%AB%E3%82%88%E3%82%8B%E3%82%AF%E3%83%AD%E3%82%B9%E3%83%97%E3%83%A9%E3%83%83%E3%83%88%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%83%A2%E3%83%90%E3%82%A4%E3%83%AB%E3%82%A2%E3%83%97%E3%83%AA%E9%96%8B%E7%99%BA-%E3%83%9E%E3%82%A4%E3%82%AF%E3%83%AD%E3%82%BD%E3%83%95%E3%83%88%E5%85%AC%E5%BC%8F%E8%A7%A3%E8%AA%AC%E6%9B%B8\/dp\/4822298868\/ref=as_li_ss_il?_encoding=UTF8&amp;pd_rd_i=4822298868&amp;pd_rd_r=83349245-6baf-11e9-8771-3903cb373890&amp;pd_rd_w=Lzhut&amp;pd_rd_wg=odKln&amp;pf_rd_p=b88353e4-7ed3-4da1-bc65-341dfa3a88ce&amp;pf_rd_r=M9XN3TMR3884V1C1CBD0&amp;psc=1&amp;refRID=M9XN3TMR3884V1C1CBD0&amp;linkCode=li2&amp;tag=typea09-22&amp;linkId=cc1d98c58145517e768832ccf59aa0d8\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/ws-fe.amazon-adsystem.com\/widgets\/q?_encoding=UTF8&amp;ASIN=4822298868&amp;Format=_SL160_&amp;ID=AsinImage&amp;MarketPlace=JP&amp;ServiceVersion=20070822&amp;WS=1&amp;tag=typea09-22\" border=\"0\"><\/a><img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" style=\"margin: 0px !important; border: currentcolor !important; border-image: none !important;\" alt=\"\" src=\"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=typea09-22&amp;l=li2&amp;o=9&amp;a=4822298868\" border=\"0\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google App Engine Java Standard + Spring Boot \u74b0\u5883\u69cb\u7bc9 Spring Boot\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3 Thymeleaf\u3092\u9069\u7528 Spring Boot\u306bVue.js\u3092\u5229\u7528\u3059\u308b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[39,108,84,109],"tags":[],"class_list":["post-554","post","type-post","status-publish","format-standard","hentry","category-android","category-ios","category-universal-windows-platform","category-xamarin"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=554"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/554\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}