{"id":4817,"date":"2019-10-27T04:25:45","date_gmt":"2019-10-26T19:25:45","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=4817"},"modified":"2019-10-27T04:25:45","modified_gmt":"2019-10-26T19:25:45","slug":"native-file-system-api%e3%81%a7%e3%83%ad%e3%83%bc%e3%82%ab%e3%83%ab%e3%81%ae%e7%94%bb%e5%83%8f%e3%82%92%e3%83%aa%e3%82%b5%e3%82%a4%e3%82%ba%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=4817","title":{"rendered":"Native File System API\u3067\u30ed\u30fc\u30ab\u30eb\u306e\u753b\u50cf\u3092\u30ea\u30b5\u30a4\u30ba\u3059\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3092\u904b\u55b6\u3057\u3066\u3044\u308b\u5f71\u97ff\u3067\u3001\u5e38\u306b\u8a18\u4e8b\u306b\u3059\u308b\u300c\u30cd\u30bf\u300d\u3092\u63a2\u3059\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u304a\u304b\u3052\u3067\u6700\u65b0\u60c5\u5831\u3082\u77e5\u308b\u3053\u3068\u304c\u591a\u304f\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u9593\u305d\u3093\u306a\u60c5\u5831\u306e\u4e2d\u306b\u300c\u3042\u308b\u6a5f\u80fd\u300d\u304c<code>Google Chrome<\/code>\u3067\u672c\u683c\u7684\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u77e5\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u306f\u4f55\u304b\u3068\u8a00\u3046\u3068\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">Native File System API<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001PC\u4e0a\u306b\u3042\u308b<strong>\u30ed\u30fc\u30ab\u30eb\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u76f4\u63a5\u30d6\u30e9\u30a6\u30b6\u3067\u64cd\u4f5c\u3059\u308b<\/strong>\u3068\u3044\u3046\u6a5f\u80fd\u3067\u3059\u306d\ud83d\ude32\u2728<\/p>\n<p>\u901a\u5e38\u30d6\u30e9\u30a6\u30b6\u3067\u30ed\u30fc\u30ab\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u64cd\u4f5c\u3059\u308b\u306b\u306f\u4e00\u5ea6\u30b5\u30fc\u30d0\u30fc\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3082\u3089\u3046\u3068\u3044\u3046\u624b\u9806\u304c\u5fc5\u8981\u3067\u3057\u305f\u304c\u3001\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u3048\u3070\u76f4\u63a5\u30ed\u30fc\u30ab\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u64cd\u4f5c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3084\u753b\u50cf\u306e\u7de8\u96c6\u306a\u3069\u3082\u30d6\u30e9\u30a6\u30b6\u3055\u3048\u3042\u308c\u3070\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3093\u3067\u3059\u3002\u3053\u308c\u3063\u3066\u3059\u3054\u3044\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u305d\u3053\u3067\uff01<\/p>\n<p>\u4eca\u56de\u306f\u3053\u306e<code>Native File System API<\/code>\u3092\u4f7f\u3063\u3066\u30ed\u30fc\u30ab\u30eb\u306b\u3042\u308b\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3057\u3066\u4fdd\u5b58\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u3001\u7686\u3055\u3093\u306e\u304a\u5f79\u306b\u7acb\u3066\u308b\u3068\u5b09\u3057\u3044\u3067\u3059\ud83d\ude0a\u2728<br \/>\n\uff08\u6700\u5f8c\u306b\u5b9f\u969b\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u307e\u3059\u3088\u266a\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3566 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png\" alt=\"\" width=\"306\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1.png 306w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_1-287x300.png 287w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Vue 2.6\u3001Bootstrap 4.3\uff08CSS\u306e\u307f\uff09<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u958b\u767a\u3059\u308b\u6a5f\u80fd\u306e\u624b\u9806\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>\u30ed\u30fc\u30ab\u30eb\u306e\u753b\u50cf\u3092\u9078\u3076<\/li>\n<li>\u5909\u66f4\u5f8c\u306e\u30b5\u30a4\u30ba\uff08\u7e26\u30fb\u6a2a\uff09\u3092\u6307\u5b9a<\/li>\n<li>\u30b5\u30a4\u30ba\u306e\u5909\u66f4\u306b\u3088\u3063\u3066\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u30d7\u30ec\u30d3\u30e5\u30fc\u753b\u50cf\u3092\u8868\u793a<\/li>\n<li>\u6307\u5b9a\u3057\u305f\u30b5\u30a4\u30ba\u3067\u753b\u50cf\u3092\u30ed\u30fc\u30ab\u30eb\u306b\u4fdd\u5b58<\/li>\n<\/ol>\n<h1 id=\"preparation\">\u6e96\u5099\u3059\u308b<\/h1>\n<p>2019.10.27\u65e5\u73fe\u5728\u3001<code>Native File System API<\/code>\u306f\u307e\u3060\u5168\u3066\u306e\u74b0\u5883\u3067\u6709\u52b9\u306b\u306f\u306a\u3063\u3066\u3044\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u3001\u3053\u306e\u6a5f\u80fd\u3092\u6709\u52b9\u306b\u3059\u308b\u305f\u3081\u306b\u306f\u4ee5\u4e0b\u306e\uff12\u3064\u306e\u65b9\u6cd5\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ol>\n<li>\u958b\u767a\u8005\u7528\u306e\u30c8\u30fc\u30af\u30f3\u3092\u4f5c\u6210\u3057\u3066\u30da\u30fc\u30b8\uff08\u3082\u3057\u304f\u306fHTTP\u30d8\u30c3\u30c0\u30fc\uff09\u306b\u57cb\u3081\u8fbc\u3080<\/li>\n<li>\u81ea\u5206\u3067Chrome\u306e\u8a2d\u5b9a\u3092\u5909\u3048\u308b<\/li>\n<\/ol>\n<p>\uff11\u756a\u76ee\u3067\u5b9f\u884c\u3059\u308b\u3068\u3001\u30e6\u30fc\u30b6\u30fc\u306f\u7279\u5225\u4f55\u3082\u3057\u306a\u304f\u3066\u3082<code>Native File System API<\/code>\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u306e\u3067\u3059\u304c\u3001\u6b8b\u5ff5\u306a\u3053\u3068\u306b\u30c8\u30fc\u30af\u30f3\u306b\u306f\u6709\u52b9\u671f\u9650\u304c\u3042\u308b\u306e\u3067\u4eca\u56de\u306f\uff12\u756a\u76ee\u306e\u8a2d\u5b9a\u3092\u5909\u3048\u308b\u65b9\u6cd5\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001<a href=\"chrome:\/\/flags\/\">chrome:\/\/flags\/<\/a>\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3059\u308b\u3068\u30da\u30fc\u30b8\u4e0a\u90e8\u306b\u691c\u7d22\u30dc\u30c3\u30af\u30b9\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u3053\u3053\u306b<strong>\u300cnative file system api\u300d<\/strong>\u3068\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u9078\u5225\u3057\u3066\u304f\u308c\u307e\u3059\u306e\u3067\u3001<code>Native File System API<\/code>\u3092\u6709\u52b9\uff08Enable\uff09\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4821\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_1.png\" alt=\"\" width=\"871\" height=\"292\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_1.png 871w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_1-300x101.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_1-768x257.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>\u3059\u308b\u3068\u3001\u30da\u30fc\u30b8\u53f3\u4e0b\u306b<strong>\u300cRelaunch\u300d<\/strong>\u30dc\u30bf\u30f3\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u30af\u30ea\u30c3\u30af\u3057\u3066\u30d6\u30e9\u30a6\u30b6\u3092\u518d\u8d77\u52d5\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4820\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_2.png\" alt=\"\" width=\"159\" height=\"69\" \/><\/p>\n<p>\u306a\u304a\u3001\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u8003\u616e\u3057\u3066\u304b<code>Native File System API<\/code>\u306f<code>HTTPS<\/code>\u3067\u3057\u304b\u52d5\u304d\u307e\u305b\u3093\u3002\u3082\u3057\u30ed\u30fc\u30ab\u30eb\u306b<code>HTTPS<\/code>\u74b0\u5883\u3092\u3064\u304f\u308b\u5834\u5408\u306f<a href=\"https:\/\/blog.capilano-fw.com\/?p=2228\">\u30b3\u30d4\u30da\u3067OK\uff01\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306bHTTPS\u3092\u5c0e\u5165\u3059\u308b\uff08nginx\u7de8\uff09<\/a>\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3067\u306f\u3001\u6b21\u306e\u9805\u76ee\u304b\u3089\u5b9f\u969b\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\uff01<\/p>\n<h1>\u57fa\u672c\u5f62\u3092\u3064\u304f\u308b<\/h1>\n<p>\u307e\u305a\u306f\u57fa\u672c\u306b\u306a\u308b\u90e8\u5206\u306e<code>HTML<\/code>\u3068<code>JavaScript<\/code>\u3067\u3059\u3002<\/p>\n<pre>&lt;html&gt;\r\n&lt;head&gt;\r\n    <strong>&lt;link href=\"https:\/\/stackpath.bootstrapcdn.com\/bootstrap\/4.3.1\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\r\n<\/strong>&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=\"app\" class=\"p-3\"&gt;\r\n\r\n    &lt;!-- \u3053\u3053\u306b\u753b\u50cf\u30ea\u30b5\u30a4\u30ba\u30fb\u30b3\u30f3\u30c6\u30f3\u30c4 --&gt;\r\n\r\n&lt;\/div&gt;\r\n<strong>&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue@2.6.0\"&gt;&lt;\/script&gt;\r\n<\/strong>&lt;script&gt;\r\n\r\n    new Vue({\r\n        el: '#app',\r\n        <strong>data: {\r\n            imageData: null,\r\n            resizingWidth: 0,\r\n            resizingHeight: 0\r\n        }<\/strong>\r\n    });\r\n\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u3053\u3053\u3067\u306f\u3001<code>Vue<\/code>\u3068<code>Bootstrap<\/code>\uff08CSS\u306e\u307f\uff09\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b<code>CDN<\/code>\u3067\u8aad\u307f\u8fbc\u307f\u3001\u3055\u3089\u306b<code>Vue<\/code>\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u5909\u6570\u3092\u7528\u610f\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li>imageData\u3000\u30fb\u30fb\u30fb\u3000\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u306e\u30c7\u30fc\u30bf\u304c\u5165\u308b<\/li>\n<li>resizingWidth, resizingHeight\u3000\u30fb\u30fb\u30fb\u3000\u30ea\u30b5\u30a4\u30ba\u3059\u308b\u7e26\u6a2a\u30b5\u30a4\u30ba<\/li>\n<\/ul>\n<h1>\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3059\u308b\u90e8\u5206\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306b\u3042\u308b\u753b\u50cf\u3092\u9078\u629e\u3059\u308b\u90e8\u5206\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>&lt;div id=\"app\" class=\"p-3\"&gt;\r\n    <strong>&lt;button class=\"btn btn-primary\" @click=\"chooseFile\"&gt;\u30ea\u30b5\u30a4\u30ba\u3059\u308b\u753b\u50cf\u3092\u9078\u629e&lt;\/button&gt;<\/strong>\r\n&lt;\/div&gt;<\/pre>\n<p>HTML\u5074\u306b\u306f\u30dc\u30bf\u30f3\u3092\u4f5c\u308a\u3001\u30af\u30ea\u30c3\u30af\u3057\u305f\u6642\u306b\u5b9f\u884c\u3055\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3092<code>Vue<\/code>\u5074\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>new Vue({\r\n\r\n    \/\/ \u7701\u7565\r\n\r\n    computed: {\r\n        <strong>imageContents() {<\/strong>\r\n\r\n<strong>            if(this.imageData !== null) {<\/strong>\r\n\r\n<strong>                \/\/ img \u30bf\u30b0\u304c\u8aad\u307f\u8fbc\u3081\u308b\u5f62\u5f0f\u306b\u5909\u63db<\/strong>\r\n<strong>                return URL.createObjectURL(this.imageData);<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    },\r\n    methods: {\r\n        <strong>async chooseFile() {<\/strong>\r\n\r\n<strong>            const options = {<\/strong>\r\n<strong>                accepts: [{<\/strong>\r\n<strong>                    mimeTypes: ['image\/png', 'image\/jpeg', 'image\/gif']   \/\/ \u753b\u50cf\u3060\u3051\u8a31\u53ef<\/strong>\r\n<strong>                }],<\/strong>\r\n<strong>            };<\/strong>\r\n<strong>            const handle = await window.chooseFileSystemEntries(options);<\/strong>\r\n<strong>            this.imageData = await handle.getFile();<\/strong>\r\n\r\n<strong>            let img = new Image();<\/strong>\r\n<strong>            img.onload = () =&gt; {<\/strong>\r\n\r\n<strong>                \/\/ \u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3092\u53d6\u5f97<\/strong>\r\n<strong>                this.resizingWidth = img.width;<\/strong>\r\n<strong>                this.resizingHeight = img.height;<\/strong>\r\n\r\n<strong>            };<\/strong>\r\n<strong>            img.src = this.imageContents;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    }\r\n});<\/pre>\n<p>\u307e\u305a\u3001\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u304c<code>computed<\/code>\u306b\u3042\u308b<code>imageContents()<\/code>\u3067\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u3001\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u30c7\u30fc\u30bf\u306f\u305d\u306e\u307e\u307e\u3067\u306f<code>&lt;img&gt;<\/code>\u30bf\u30b0\u3067\u306f\u8868\u793a\u3067\u304d\u306a\u3044\u306e\u3067\u3001<code>URL.createObjectURL()<\/code>\u3092\u4f7f\u3063\u3066\u5909\u63db\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001<code>chooseFileSystemEntries()<\/code>\u304c\u753b\u50cf\u3092\u9078\u629e\u3059\u308b\u90e8\u5206\u3067\u3001\u3082\u3057\u9078\u629e\u3055\u308c\u305f\u3089<code>getFile()<\/code>\u3092\u5b9f\u884c\u3057\u3001\u4e2d\u8eab\u3092\u5909\u6570<code>imageData<\/code>\u306b\u683c\u7d0d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u203b \u3053\u306e<code>imageData<\/code>\u304c\u5143\u306b\u306a\u3063\u3066<code>imageContents()<\/code>\u3067\u30c7\u30fc\u30bf\u5909\u63db\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u3053\u306e\u307e\u307e\u3067\u306f\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u306e\u7e26\u6a2a\u30b5\u30a4\u30ba\u304c\u308f\u304b\u308a\u307e\u305b\u3093\u306e\u3067\u3001<code>new Image()<\/code>\u3092\u4f7f\u3063\u3066\u305d\u308c\u3089\u3092\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u9078\u629e\u753b\u50cf\u306e\u30d7\u30ec\u30d3\u30e5\u30fc\u90e8\u5206\u3092\u3064\u304f\u308b<\/h1>\n<p>\u7d9a\u3044\u3066\u306f\u3001\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u3092\u30d7\u30ec\u30d3\u30e5\u30fc\u8868\u793a\u3059\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<pre>&lt;div id=\"app\" class=\"p-3\"&gt;\r\n\r\n    &lt;!-- \u7701\u7565 --&gt;\r\n\r\n    <strong>&lt;div v-if=\"imageContents\"&gt;<\/strong>\r\n<strong>        &lt;hr&gt;<\/strong>\r\n<strong>        &lt;div class=\"my-3\"&gt;<\/strong>\r\n<strong>            \u5909\u66f4\u5f8c\u306e\u30b5\u30a4\u30ba\u306f\uff1f\uff1f&lt;br&gt;<\/strong>\r\n<strong>            &lt;input type=\"number\" min=\"1\" v-model=\"resizingWidth\"&gt; \u00d7 &lt;input type=\"number\" min=\"1\" v-model=\"resizingHeight\"&gt;<\/strong>\r\n<strong>            &amp;nbsp;<\/strong>\r\n<strong>            &lt;button class=\"btn btn-success\" @click=\"save\"&gt;\u4fdd\u5b58\u3059\u308b&lt;\/button&gt;<\/strong>\r\n<strong>        &lt;\/div&gt;<\/strong>\r\n<strong>        &lt;strong&gt;\u753b\u50cf\u30d7\u30ec\u30d3\u30e5\u30fc&lt;\/strong&gt;<\/strong>\r\n<strong>        &lt;br&gt;<\/strong>\r\n<strong>        &lt;img :style=\"previewStyles\" :src=\"imageContents\"&gt;<\/strong>\r\n<strong>    &lt;\/div&gt;<\/strong>\r\n&lt;\/div&gt;<\/pre>\n<p>\u3053\u3053\u3067\u3084\u3063\u3066\u3044\u308b\u306e\u306f\u3001\u307e\u305a\u5148\u307b\u3069\u3064\u304f\u3063\u305f<code>imageContents()<\/code><\/p>\n<p>\u306e\u4e2d\u8eab\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092<code>v-if<\/code>\u3067\u30c1\u30a7\u30c3\u30af\u3057\u3001\u3082\u3057\u5b58\u5728\u3057\u3066\u3044\u308c\u3070\uff08\u3064\u307e\u308a\u3001\u753b\u50cf\u304c\u9078\u629e\u3055\u308c\u3066\u3044\u308c\u3070\uff09\u30d7\u30ec\u30d3\u30e5\u30fc\u753b\u50cf\u3092\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30d7\u30ec\u30d3\u30e5\u30fc\u753b\u50cf\u306e\u4e0a\u306b\u306f\u7e26\u6a2a\u306e\u30b5\u30a4\u30ba\u3092\u6307\u5b9a\u3067\u304d\u308b\u3088\u3046\u5165\u529b\u30dc\u30c3\u30af\u30b9\u3092\uff12\u3064\u7528\u610f\u3057\u3001<code>v-model<\/code>\u3092\u4f7f\u3063\u3066<code>Vue<\/code>\u306e\u5909\u6570\u3068\u9023\u52d5\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4828\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3-1.png\" alt=\"\" width=\"565\" height=\"81\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3-1.png 565w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3-1-300x43.png 300w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u3053\u306e\u7e26\u6a2a\u30b5\u30a4\u30ba\u306f\u6307\u5b9a\u3055\u308c\u305f\u6570\u5024\u306b\u3088\u3063\u3066\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u306b\u30d7\u30ec\u30d3\u30e5\u30fc\u753b\u50cf\u306b\u53cd\u6620\u3055\u308c\u308b\u3088\u3046\u306b<code>previewStyles<\/code>\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u6307\u5b9a\u3059\u308b\u3088\u3046\u306b\u3057\u3001\u3055\u3089\u306b\u3001\u753b\u50cf\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u30dc\u30bf\u30f3\u306b\u306f<code>save<\/code>\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3082\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3089\uff12\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>new Vue({\r\n\r\n    \/\/ \u7701\u7565\r\n\r\n    computed: {\r\n\r\n        \/\/ \u7701\u7565\r\n\r\n        <strong>previewStyles() {<\/strong>\r\n\r\n<strong>            let styles = {};<\/strong>\r\n\r\n<strong>            if(this.resizingWidth &gt; 0) {<\/strong>\r\n\r\n<strong>                \/\/ \u6a2a\u5e45\u3092 300px \u306b\u3057\u305f\u3068\u304d\u306e\u9ad8\u3055\u3092\u8a08\u7b97<\/strong>\r\n<strong>                const width = 300;<\/strong>\r\n<strong>                const height = width \/ this.resizingWidth * this.resizingHeight;<\/strong>\r\n<strong>                styles = {<\/strong>\r\n<strong>                    width: width +'px',<\/strong>\r\n<strong>                    height: height +'px',<\/strong>\r\n<strong>                    border: '3px solid #000'<\/strong>\r\n<strong>                };<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>            return styles;<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    },\r\n    methods: {\r\n\r\n        \/\/ \u7701\u7565\r\n\r\n        <strong>async save() {<\/strong>\r\n\r\n<strong>            let canvas = document.createElement('canvas');<\/strong>\r\n<strong>            let ctx = canvas.getContext('2d');<\/strong>\r\n<strong>            canvas.width = this.resizingWidth;<\/strong>\r\n<strong>            canvas.height = this.resizingHeight;<\/strong>\r\n\r\n<strong>            let img = new Image();<\/strong>\r\n<strong>            img.onload = () =&gt; {<\/strong>\r\n\r\n<strong>                \/\/ canvas\u306b\u30ea\u30b5\u30a4\u30ba\u3057\u305f\u753b\u50cf\u3092\u63cf\u753b<\/strong>\r\n<strong>                ctx.drawImage(img, 0, 0, this.resizingWidth, this.resizingHeight);<\/strong>\r\n<strong>                canvas.toBlob(this.saveImage);<\/strong>\r\n\r\n<strong>            };<\/strong>\r\n<strong>            img.src = this.imageContents;<\/strong>\r\n\r\n<strong>        },<\/strong>\r\n<strong>        async saveImage(resizedImageData) {<\/strong>\r\n\r\n<strong>            const options = {<\/strong>\r\n<strong>                type: 'saveFile',   \/\/ \u30bb\u30fc\u30d6\u30e2\u30fc\u30c9<\/strong>\r\n<strong>                accepts: [{<\/strong>\r\n<strong>                    mimeTypes: ['image\/png']<\/strong>\r\n<strong>                }],<\/strong>\r\n<strong>            };<\/strong>\r\n<strong>            const handle = await window.chooseFileSystemEntries(options);<\/strong>\r\n<strong>            const writer = await handle.createWriter();<\/strong>\r\n<strong>            await writer.truncate(0);<\/strong>\r\n<strong>            await writer.write(0, resizedImageData);<\/strong>\r\n<strong>            await writer.close();<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n    }\r\n});<\/pre>\n<p>\u307e\u305a<code>previewStyles()<\/code>\u3067\u306f\u3001\u6a2a\u5e45\u3092300px\u306b\u56fa\u5b9a\u3057\u305f\u5834\u5408\u9ad8\u3055\u304c\u3044\u304f\u3089\u306b\u306a\u308b\u304b\u3092\u8a08\u7b97\u3057\u3001\u305d\u308c\u3092\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u306b\u53cd\u6620\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001<code>save()<\/code>\u3067\u306f\u3001JavaScript\u5185\u3067<code>&lt;canvas&gt;&lt;\/canvas&gt;<\/code>\u3092\u4f5c\u6210\u3057\u3001\u305d\u3053\u306b\u9078\u629e\u3055\u308c\u305f\u753b\u50cf\u3092\u63cf\u753b\u3059\u308b\u3053\u3068\u3067\u30ea\u30b5\u30a4\u30ba\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u5b9f\u969b\u306b\u753b\u50cf\u3092\u4fdd\u5b58\u3059\u308b\u90e8\u5206\u306f<code>saveImage()<\/code>\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u3053\u3053\u3067\u306f\u30bb\u30fc\u30d6\u30e2\u30fc\u30c9\u3092\u6307\u5b9a\u3057\u305f<code>chooseFileSystemEntries()<\/code>\u3092\u4f7f\u3063\u3066\u30d5\u30a1\u30a4\u30eb\u3092\u66f8\u304d\u8fbc\u3080\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u203b \u4eca\u56de\u306f\u8aac\u660e\u304c\u8907\u96d1\u306b\u306a\u308b\u305f\u3081<code>image\/png<\/code>\u306e\u307f\u3092\u6709\u52b9\u306b\u3057\u307e\u3057\u305f\u304c\u3001<code>toBlob()<\/code>\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3059\u308b\u3068<code>jpeg<\/code>\u3082\u5bfe\u5fdc\u3067\u304d\u307e\u3059\u3002\u305d\u306e\u5834\u5408\u3001\u30e9\u30b8\u30aa\u30dc\u30bf\u30f3\u306a\u3069\u3067<code>png<\/code>\u3084<code>jpeg<\/code>\u306a\u3069\u753b\u50cf\u5f62\u5f0f\u304c\u9078\u629e\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u3068\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<pre>canvas.toBlob(this.saveImage, <strong>'image\/jpeg'<\/strong>);<\/pre>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\uff01<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u4eca\u56de\u958b\u767a\u3057\u305f\u5185\u5bb9\u3092\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><iframe loading=\"lazy\" title=\"Native File System API\u3067\u30ed\u30fc\u30ab\u30eb\u306e\u753b\u50cf\u3092\u30ea\u30b5\u30a4\u30ba\" width=\"525\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/8IipCaV4mZY?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>\u306f\u3044\uff01\u3046\u307e\u304f\u3044\u304d\u307e\u3057\u305f\ud83d\ude0a\u2728<\/p>\n<p>\u5b9f\u969b\u306b\u30ea\u30b5\u30a4\u30ba\u3057\u305f\u753b\u50cf\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4822\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3.png\" alt=\"\" width=\"500\" height=\"500\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3.png 500w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3-150x150.png 150w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3-300x300.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/10\/native_file_system_api_3-100x100.png 100w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<h1>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b<\/h1>\n<p>\u4eca\u56de\u5b9f\u969b\u306b\u958b\u767a\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u4ee5\u4e0b\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b \u305f\u3060\u3057\u3001<a href=\"#preparation\">\u6e96\u5099\u3059\u308b<\/a>\u3067\u8aac\u660e\u3057\u305f\u5185\u5bb9\u3092\u5168\u3066\u5b9f\u884c\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<a  data-e-Disable-Page-Transition=\"true\" class=\"download-link\" title=\"\" href=\"https:\/\/blog.capilano-fw.com?download=4823&amp;tmstv=1777432949\" rel=\"nofollow\" id=\"download-link-4823\" data-redirect=\"false\" >\n\tNative File System API\u3067\u753b\u50cf\u3092\u30ea\u30b5\u30a4\u30ba<\/a>\n\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306f\u6bd4\u8f03\u7684\u65b0\u3057\u3044\u6a5f\u80fd\u306e<code>Native File System API<\/code>\u3092\u4f7f\u3063\u3066\u753b\u50cf\u3092\u30ea\u30b5\u30a4\u30ba\u3059\u308b\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u3046\u3044\u3046\u6a5f\u80fd\u304c\u30c9\u30f3\u30c9\u30f3\u6709\u52b9\u306b\u306a\u3063\u3066\u304f\u308b\u3068\u30a6\u30a7\u30d6\u3068\u30ed\u30fc\u30ab\u30eb\u306e\u57a3\u6839\u3082\u3082\u3063\u3068\u4f4e\u304f\u306a\u3063\u3066\u3044\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u305d\u306e\u53cd\u9762\u3044\u304b\u306b\u9ad8\u3044\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u3092\u5b9f\u73fe\u3059\u308b\u304b\u3068\u3044\u3046\u306e\u3082\u91cd\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u308f\u3051\u3067\u3001\u4fbf\u5229\u3055\u3068\u5371\u967a\u306f\u5207\u308a\u96e2\u305b\u306a\u3044\u3082\u306e\u306a\u3093\u3060\u306a\u3068\u3082\u611f\u3058\u307e\u3057\u305f\u3002<\/p>\n<p>\u307e\u305f\u3001\u4eca\u5f8c<code>Native File System API<\/code>\u3092\u4f7f\u3046\u3068\u3069\u3093\u306a\u3053\u3068\u304c\u5b9f\u73fe\u3067\u304d\u308b\u3060\u308d\u3046\u304b\u3068\u3044\u3046\u90e8\u5206\u3067\u3059\u304c\u3001<a href=\"https:\/\/web.dev\/native-file-system\">web.dev<\/a>\u306e\u8aac\u660e\u66f8\u304d\u306b\u306fIDE\uff08\u7d71\u5408\u958b\u767a\u74b0\u5883\uff09\u3084\u753b\u50cf\u30a8\u30c7\u30a3\u30bf\u30fc\u306a\u3069\u3001\u3068\u8a00\u53ca\u3057\u3066\u3042\u308b\u306e\u3067\u3001\u4eca\u5f8c<code>paiza<\/code>\u3084<code>cloud 9<\/code>\u306a\u3093\u304b\u3082\u3053\u306e\u6a5f\u80fd\u3092\u53d6\u308a\u5165\u308c\u3066\u3044\u304f\u306e\u304b\u306a\u3001\u306a\u3093\u3066\u601d\u3044\u307e\u3057\u305f\u3002\uff08\u3082\u3057\u304b\u3057\u3066\u3082\u3046\u3084\u3063\u3066\u308b\uff1f\uff1f\uff1f\uff09<\/p>\n<p>\u3068\u306b\u304b\u304f\u3001\u4eca\u56de\u306f\u4e45\u3057\u3076\u308a\u306b\u65b0\u3057\u3044\u6a5f\u80fd\u306b\u6311\u6226\u3057\u305f\u306e\u3067\u697d\u3057\u304b\u3063\u305f\u3067\u3059\u3002<\/p>\n<p>\u307f\u306a\u3055\u3093\u3082\u305c\u3072\u3084\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2595 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/7.png\" alt=\"\" width=\"226\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/7.png 226w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2018\/11\/7-212x300.png 212w\" sizes=\"auto, (max-width: 226px) 100vw, 226px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u30d6\u30ed\u30b0\u3092\u904b\u55b6\u3057\u3066\u3044\u308b\u5f71\u97ff\u3067\u3001\u5e38\u306b\u8a18\u4e8b\u306b\u3059\u308b\u300c\u30cd\u30bf\u300d\u3092\u63a2\u3059\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u304a\u304b\u3052\u3067\u6700\u65b0\u60c5\u5831\u3082\u77e5\u308b\u3053\u3068\u304c\u591a\u304f\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002 \u305d\u3057\u3066\u3001\u3053 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=4817\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Native File System API\u3067\u30ed\u30fc\u30ab\u30eb\u306e\u753b\u50cf\u3092\u30ea\u30b5\u30a4\u30ba\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":4830,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,12,15],"tags":[16],"class_list":["post-4817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-vue-js","category-15","tag-google-chrome"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/4817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4817"}],"version-history":[{"count":5,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/4817\/revisions"}],"predecessor-version":[{"id":4829,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/4817\/revisions\/4829"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/4830"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}