{"id":30956,"date":"2025-10-04T00:41:32","date_gmt":"2025-10-03T21:41:32","guid":{"rendered":"https:\/\/fatihsoysal.com\/blog\/?p=30956"},"modified":"2025-10-04T00:41:32","modified_gmt":"2025-10-03T21:41:32","slug":"vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma","status":"publish","type":"post","link":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/","title":{"rendered":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma"},"content":{"rendered":"<p><body><\/p>\n<h2>Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma<\/h2>\n<h2>Giri\u015f<\/h2>\n<p>Web uygulamalar\u0131 g\u00fcn\u00fcm\u00fczde sadece sunucu taraf\u0131nda i\u015flenen verilerle de\u011fil, ayn\u0131 zamanda kullan\u0131c\u0131lar\u0131n yerel sistemlerinden y\u00fckledi\u011fi dosyalarla da etkile\u015fime girmektedir. Bir resim y\u00fckleme, bir metin belgesini \u00f6nizleme veya bir CSV dosyas\u0131n\u0131 istemci taraf\u0131nda i\u015fleme gibi senaryolar, modern web uygulamalar\u0131 i\u00e7in temel gereksinimler haline gelmi\u015ftir. JavaScript&#8217;in yerle\u015fik <code>FileReader<\/code> API&#8217;si, bu t\u00fcr dosya okuma i\u015flemlerini taray\u0131c\u0131 ortam\u0131nda kolayca ger\u00e7ekle\u015ftirmemizi sa\u011flar. Vue.js gibi reaktif ve bile\u015fen tabanl\u0131 bir framework ile <code>FileReader<\/code> API&#8217;sini birle\u015ftirmek, kullan\u0131c\u0131 dostu ve y\u00f6netilebilir dosya okuyucu bile\u015fenleri olu\u015fturmak i\u00e7in g\u00fc\u00e7l\u00fc bir y\u00f6ntem sunar.<\/p>\n<p>Bu makalede, <code>FileReader<\/code> API&#8217;sinin temel prensiplerini, Vue.js ile nas\u0131l entegre edilece\u011fini ve farkl\u0131 dosya tiplerini okumak i\u00e7in nas\u0131l kullan\u0131labilece\u011fini ad\u0131m ad\u0131m inceleyece\u011fiz. Amac\u0131m\u0131z, kullan\u0131c\u0131lar\u0131n yerel dosyalar\u0131n\u0131 se\u00e7ip i\u00e7eriklerini web uygulaman\u0131zda g\u00f6r\u00fcnt\u00fclemelerine veya i\u015flemelerine olanak tan\u0131yan, yeniden kullan\u0131labilir bir Vue..js bile\u015feni olu\u015fturmakt\u0131r. Makale boyunca, teorik bilgileri pratik kod \u00f6rnekleriyle destekleyerek, kendi dosya okuyucu bile\u015fenlerinizi geli\u015ftirmeniz i\u00e7in kapsaml\u0131 bir rehber sunaca\u011f\u0131z.<\/p>\n<h2>Temel Kavramlar<\/h2>\n<p>Dosya okuyucu bile\u015fenimizi geli\u015ftirmeye ba\u015flamadan \u00f6nce, temel te\u015fkil eden <code>FileReader<\/code> API&#8217;si ve Vue.js&#8217;in ilgili y\u00f6nlerini anlamak \u00f6nemlidir.<\/p>\n<h3>FileReader API Nedir?<\/h3>\n<p><code>FileReader<\/code> API&#8217;si, web uygulamalar\u0131n\u0131n kullan\u0131c\u0131n\u0131n bilgisayar\u0131ndaki dosyalar\u0131n veya ham veri arabelleklerinin (Blob&#8217;lar) i\u00e7eri\u011fini asenkron olarak okumas\u0131n\u0131 sa\u011flayan bir JavaScript aray\u00fcz\u00fcd\u00fcr. Bu API, \u00f6zellikle <code><input type=\"file\"><\/code> elementi arac\u0131l\u0131\u011f\u0131yla se\u00e7ilen dosyalar\u0131n i\u00e7eri\u011fini okumak i\u00e7in kullan\u0131l\u0131r. G\u00fcvenlik nedeniyle, <code>FileReader<\/code> API&#8217;si kullan\u0131c\u0131n\u0131n izni olmadan dosya sistemine do\u011frudan eri\u015femez; dosya okuma i\u015flemi yaln\u0131zca kullan\u0131c\u0131 taraf\u0131ndan a\u00e7\u0131k\u00e7a se\u00e7ilen dosyalar \u00fczerinde ger\u00e7ekle\u015ftirilebilir.<\/p>\n<p><code>FileReader<\/code> nesnesinin ba\u015fl\u0131ca \u00f6zellikleri \u015funlard\u0131r:<br \/>\n*   <strong>Asenkron \u00c7al\u0131\u015fma:<\/strong> Dosya okuma i\u015flemleri uzun s\u00fcrebilece\u011finden, taray\u0131c\u0131 aray\u00fcz\u00fcn\u00fc kilitlememek i\u00e7in asenkron olarak \u00e7al\u0131\u015f\u0131r. Okuma i\u015flemi tamamland\u0131\u011f\u0131nda veya bir hata olu\u015ftu\u011funda belirli olaylar tetiklenir.<br \/>\n*   <strong>Blob ve File Nesneleri:<\/strong> <code>FileReader<\/code> do\u011frudan bir <code>File<\/code> nesnesi (ki bu asl\u0131nda \u00f6zel bir <code>Blob<\/code> t\u00fcr\u00fcd\u00fcr) veya genel bir <code>Blob<\/code> nesnesi \u00fczerinde \u00e7al\u0131\u015f\u0131r. <code>File<\/code> nesneleri, kullan\u0131c\u0131n\u0131n <code><input type=\"file\"><\/code> arac\u0131l\u0131\u011f\u0131yla se\u00e7ti\u011fi dosyalara kar\u015f\u0131l\u0131k gelir ve <code>name<\/code>, <code>size<\/code>, <code>type<\/code> gibi ek \u00f6zelliklere sahiptir.<br \/>\n*   <strong>Okuma Metotlar\u0131:<\/strong> <code>FileReader<\/code>&#8216;\u0131n i\u00e7eri\u011fi farkl\u0131 formatlarda okumak i\u00e7in \u00e7e\u015fitli metotlar\u0131 vard\u0131r:<br \/>\n    *   <code>readAsText(file, [encoding])<\/code>: Dosyan\u0131n i\u00e7eri\u011fini metin olarak okur. Genellikle <code>.txt<\/code>, <code>.json<\/code>, <code>.csv<\/code> gibi metin tabanl\u0131 dosyalar i\u00e7in kullan\u0131l\u0131r. \u0130ste\u011fe ba\u011fl\u0131 olarak bir karakter kodlamas\u0131 (\u00f6rne\u011fin, &#8216;UTF-8&#8217;) belirtebilirsiniz.<br \/>\n    *   <code>readAsDataURL(file)<\/code>: Dosyan\u0131n i\u00e7eri\u011fini bir Base64 kodlu veri URL&#8217;si olarak okur. Bu format, resimler veya di\u011fer ikili veriler i\u00e7in yayg\u0131n olarak kullan\u0131l\u0131r ve do\u011frudan <code><img><\/code> etiketinin <code>src<\/code> \u00f6zniteli\u011finde veya CSS <code>background-image<\/code> \u00f6zelli\u011finde kullan\u0131labilir.<br \/>\n    *   <code>readAsArrayBuffer(file)<\/code>: Dosyan\u0131n i\u00e7eri\u011fini bir <code>ArrayBuffer<\/code> olarak okur. Bu, ikili verileri (\u00f6rne\u011fin, PDF, ses, video dosyalar\u0131) daha d\u00fc\u015f\u00fck seviyede i\u015flemek gerekti\u011finde kullan\u0131\u015fl\u0131d\u0131r.<br \/>\n    *   <code>readAsBinaryString(file)<\/code>: Dosyan\u0131n i\u00e7eri\u011fini ham ikili dize olarak okur. Bu metot eski ve genellikle <code>readAsArrayBuffer<\/code> yerine kullan\u0131lmas\u0131 \u00f6nerilmez.<br \/>\n*   <strong>Olaylar:<\/strong> Okuma i\u015fleminin farkl\u0131 a\u015famalar\u0131n\u0131 izlemek i\u00e7in \u00e7e\u015fitli olaylar mevcuttur:<br \/>\n    *   <code>onloadstart<\/code>: Okuma i\u015flemi ba\u015flad\u0131\u011f\u0131nda tetiklenir.<br \/>\n    *   <code>onprogress<\/code>: Okuma i\u015flemi devam ederken periyodik olarak tetiklenir, ilerleme durumunu izlemek i\u00e7in kullan\u0131labilir.<br \/>\n    *   <code>onload<\/code>: Okuma i\u015flemi ba\u015far\u0131yla tamamland\u0131\u011f\u0131nda tetiklenir. Okunan i\u00e7erik <code>reader.result<\/code> \u00f6zelli\u011finde bulunur.<br \/>\n    *   <code>onabort<\/code>: Okuma i\u015flemi <code>reader.abort()<\/code> metoduyla iptal edildi\u011finde tetiklenir.<br \/>\n    *   <code>onerror<\/code>: Okuma i\u015flemi s\u0131ras\u0131nda bir hata olu\u015ftu\u011funda tetiklenir. Hata bilgisi <code>reader.error<\/code> \u00f6zelli\u011finde bulunur.<br \/>\n    *   <code>onloadend<\/code>: Okuma i\u015flemi (ba\u015far\u0131l\u0131 veya hatal\u0131) tamamland\u0131\u011f\u0131nda tetiklenir.<\/p>\n<h3>Vue.js&#8217;e Giri\u015f<\/h3>\n<p>Vue.js, kullan\u0131c\u0131 aray\u00fczleri olu\u015fturmak i\u00e7in a\u015famal\u0131 olarak benimsenebilir bir JavaScript framework&#8217;\u00fcd\u00fcr. Temel \u00f6zellikleri aras\u0131nda reaktif veri ba\u011flama, bile\u015fen tabanl\u0131 mimari ve sanal DOM kullan\u0131m\u0131 bulunur. <code>FileReader<\/code> API&#8217;sini Vue.js ile kullan\u0131rken, Vue&#8217;nun reaktif veri sistemi sayesinde dosya okuma durumunu, ilerlemesini ve sonucunu kolayca y\u00f6netebilir ve kullan\u0131c\u0131 aray\u00fcz\u00fcn\u00fc buna g\u00f6re g\u00fcncelleyebilirsiniz. Bile\u015fen tabanl\u0131 yakla\u015f\u0131m, dosya okuyucu mant\u0131\u011f\u0131n\u0131 izole edilmi\u015f, yeniden kullan\u0131labilir bir birim olarak paketlememizi sa\u011flar.<\/p>\n<h2>Vue.js Projesi Kurulumu<\/h2>\n<p>\u0130lk ad\u0131m olarak, yeni bir Vue.js projesi olu\u015ftural\u0131m. Vue CLI (Komut Sat\u0131r\u0131 Aray\u00fcz\u00fc) bu i\u015flemi olduk\u00e7a kolayla\u015ft\u0131r\u0131r. E\u011fer Vue CLI y\u00fckl\u00fc de\u011filse, a\u015fa\u011f\u0131daki komutla global olarak y\u00fckleyebilirsiniz:<\/p>\n<pre><code class=\"language-bash\">npm install -g @vue\/cli\n<h2>Veya<\/h2>\nyarn global add @vue\/cli<\/code><\/pre>\n<p>Ard\u0131ndan, yeni bir Vue projesi olu\u015ftural\u0131m:<\/p>\n<pre><code class=\"language-bash\">vue create file-reader-app<\/code><\/pre>\n<p>Bu komut size baz\u0131 se\u00e7enekler sunacakt\u0131r (varsay\u0131lan\u0131 se\u00e7mek genellikle yeterlidir). Proje olu\u015fturulduktan sonra, proje dizinine gidin:<\/p>\n<pre><code class=\"language-bash\">cd file-reader-app<\/code><\/pre>\n<p>Ve projeyi ba\u015flat\u0131n:<\/p>\n<pre><code class=\"language-bash\">npm run serve\n<h2>Veya<\/h2>\nyarn serve<\/code><\/pre>\n<p>Bu, uygulaman\u0131z\u0131 yerel bir sunucuda (genellikle <code>http:\/\/localhost:8080<\/code>) \u00e7al\u0131\u015ft\u0131racakt\u0131r.<\/p>\n<h2>Dosya Okuyucu Bile\u015feni Tasar\u0131m\u0131<\/h2>\n<p>\u015eimdi dosya okuma i\u015flevselli\u011fini i\u00e7erecek Vue bile\u015fenini tasarlayal\u0131m. <code>src\/components<\/code> klas\u00f6r\u00fcnde <code>FileReaderComponent.vue<\/code> ad\u0131nda yeni bir dosya olu\u015ftural\u0131m.<\/p>\n<h3>Bile\u015fen Yap\u0131s\u0131<\/h3>\n<p>Vue bile\u015fenleri genellikle \u00fc\u00e7 ana b\u00f6l\u00fcmden olu\u015fur:<br \/>\n*   <code><template><\/code>: Bile\u015fenin HTML yap\u0131s\u0131n\u0131 tan\u0131mlar.<br \/>\n*   <code><script><\/code>: Bile\u015fenin JavaScript mant\u0131\u011f\u0131n\u0131 (veri, metotlar, ya\u015fam d\u00f6ng\u00fcs\u00fc kancalar\u0131) i\u00e7erir.\n*   <code><\/p>\n<style><\/code>: Bile\u015fenin CSS stilini tan\u0131mlar.<\/p>\n<h3>Gerekli Veriler<\/h3>\n<p>Bile\u015fenimizin durumunu y\u00f6netmek i\u00e7in a\u015fa\u011f\u0131daki reaktif verilere ihtiyac\u0131m\u0131z olacak:\n*   <code>selectedFile<\/code>: Kullan\u0131c\u0131n\u0131n se\u00e7ti\u011fi <code>File<\/code> nesnesini tutacak.\n*   <code>fileContent<\/code>: Okunan dosyan\u0131n i\u00e7eri\u011fini tutacak (metin veya Base64 URL).\n*   <code>fileName<\/code>, <code>fileSize<\/code>, <code>fileType<\/code>: Se\u00e7ilen dosyan\u0131n temel bilgilerini g\u00f6stermek i\u00e7in.\n*   <code>errorMessage<\/code>: Herhangi bir hata durumunda kullan\u0131c\u0131ya g\u00f6sterilecek mesaj.\n*   <code>isLoading<\/code>: Dosya okuma i\u015fleminin devam edip etmedi\u011fini belirtmek i\u00e7in bir boolean bayrak.\n*   <code>progress<\/code>: Dosya okuma ilerlemesini y\u00fczde olarak tutacak.<\/p>\n<h3>Kullan\u0131c\u0131 Aray\u00fcz\u00fc<\/h3>\n<p>Kullan\u0131c\u0131 aray\u00fcz\u00fc i\u00e7in bir dosya se\u00e7me input'u, se\u00e7ilen dosyan\u0131n bilgilerini g\u00f6steren alanlar, okunan i\u00e7eri\u011fi g\u00f6steren bir \u00f6nizleme alan\u0131 ve hata\/y\u00fckleme g\u00f6stergeleri yer alacak.<\/p>\n<pre><code class=\"language-vue\"><!-- src\/components\/FileReaderComponent.vue -->\n<template>\n  <div class=\"file-reader-container\">\n    <h2>Dosya Okuyucu<\/h2>\n\n    <div class=\"file-input-section\">\n      <label for=\"file-upload\" class=\"custom-file-upload\">\n        Dosya Se\u00e7\n      <\/label>\n      <input\n        id=\"file-upload\"\n        type=\"file\"\n        @change=\"handleFileChange\"\n        accept=\".txt,.json,.csv,image\/*\"\n      \/>\n      <span v-if=\"selectedFile\" class=\"selected-file-name\">\n        Se\u00e7ilen Dosya: {{ selectedFile.name }}\n      <\/span>\n      <span v-else class=\"no-file-selected\">\n        Hen\u00fcz dosya se\u00e7ilmedi.\n      <\/span>\n    <\/div>\n\n    <div v-if=\"errorMessage\" class=\"error-message\">\n      {{ errorMessage }}\n    <\/div>\n\n    <div v-if=\"isLoading\" class=\"loading-indicator\">\n      <p>Dosya okunuyor... ({{ progress }}%)<\/p>\n      <div class=\"progress-bar-container\">\n        <div class=\"progress-bar\" :style=\"{ width: progress + '%' }\"><\/div>\n      <\/div>\n    <\/div>\n\n    <div v-if=\"selectedFile &#038;&#038; !isLoading &#038;&#038; !errorMessage\" class=\"file-info-section\">\n      <h3>Dosya Bilgileri:<\/h3>\n      <p><strong>Ad\u0131:<\/strong> {{ fileName }}<\/p>\n      <p><strong>Boyutu:<\/strong> {{ formattedFileSize }}<\/p>\n      <p><strong>Tipi:<\/strong> {{ fileType }}<\/p>\n    <\/div>\n\n    <div v-if=\"fileContent &#038;&#038; !isLoading &#038;&#038; !errorMessage\" class=\"file-content-section\">\n      <h3>Dosya \u0130\u00e7eri\u011fi \u00d6nizlemesi:<\/h3>\n      <div v-if=\"isImage\" class=\"image-preview\">\n        <img :src=\"fileContent\" :alt=\"fileName\" \/>\n      <\/div>\n      <div v-else-if=\"isText\" class=\"text-preview\">\n        <pre>{{ fileContent }}<\/pre>\n<\/p><\/div>\n<div v-else class=\"unsupported-preview\">\n<p>Bu dosya t\u00fcr\u00fc i\u00e7in \u00f6nizleme desteklenmiyor.<\/p>\n<p>\u0130\u00e7erik t\u00fcr\u00fc: {{ fileType }}<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<p><\/template><\/p>\n<p><script>\nexport default {\n  name: 'FileReaderComponent',\n  data() {\n    return {\n      selectedFile: null,\n      fileContent: null,\n      fileName: '',\n      fileSize: 0,\n      fileType: '',\n      errorMessage: '',\n      isLoading: false,\n      progress: 0,\n    };\n  },\n  computed: {\n    formattedFileSize() {\n      if (this.fileSize === 0) return '0 Bytes';\n      const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n      const i = parseInt(Math.floor(Math.log(this.fileSize) \/ Math.log(1024)));\n      return Math.round(this.fileSize \/ Math.pow(1024, i), 2) + ' ' + sizes[i];\n    },\n    isImage() {\n      return this.fileType.startsWith('image\/');\n    },\n    isText() {\n      return this.fileType.startsWith('text\/') ||\n             this.fileType === 'application\/json' ||\n             this.fileType === 'application\/csv'; \/\/ Yayg\u0131n metin tabanl\u0131 t\u00fcrler\n    }\n  },\n  methods: {\n    handleFileChange(event) {\n      this.resetState(); \/\/ \u00d6nceki durumu temizle\n      const file = event.target.files[0];<\/p>\n<p>      if (!file) {\n        this.errorMessage = 'Dosya se\u00e7ilmedi.';\n        return;\n      }<\/p>\n<p>      \/\/ Dosya boyutu kontrol\u00fc (\u00f6rne\u011fin, 5MB'dan b\u00fcy\u00fck olmas\u0131n)\n      const MAX_FILE_SIZE = 5 <em> 1024 <\/em> 1024; \/\/ 5 MB\n      if (file.size > MAX_FILE_SIZE) {\n        this.errorMessage = <code>Dosya boyutu ${this.formattedFileSize} \u00e7ok b\u00fcy\u00fck. Maksimum ${this.formatBytes(MAX_FILE_SIZE)} olmal\u0131d\u0131r.<\/code>;\n        return;\n      }<\/p>\n<p>      this.selectedFile = file;\n      this.fileName = file.name;\n      this.fileSize = file.size;\n      this.fileType = file.type || 'Bilinmeyen Tip'; \/\/ type bo\u015f olabilir<\/p>\n<p>      this.readFile();\n    },\n    readFile() {\n      this.isLoading = true;\n      this.errorMessage = '';\n      this.fileContent = null;\n      this.progress = 0;<\/p>\n<p>      const reader = new FileReader();<\/p>\n<p>      reader.onloadstart = () => {\n        this.progress = 0;\n      };<\/p>\n<p>      reader.onprogress = (event) => {\n        if (event.lengthComputable) {\n          this.progress = Math.round((event.loaded \/ event.total) * 100);\n        }\n      };<\/p>\n<p>      reader.onload = (e) => {\n        this.fileContent = e.target.result;\n        this.isLoading = false;\n        this.progress = 100; \/\/ Okuma tamamland\u0131\u011f\u0131nda %100 yap\n      };<\/p>\n<p>      reader.onerror = (e) => {\n        this.errorMessage = 'Dosya okuma hatas\u0131: ' + e.target.error.message;\n        this.isLoading = false;\n        this.fileContent = null;\n      };<\/p>\n<p>      reader.onabort = () => {\n        this.errorMessage = 'Dosya okuma i\u015flemi iptal edildi.';\n        this.isLoading = false;\n        this.fileContent = null;\n      };<\/p>\n<p>      \/\/ Dosya tipine g\u00f6re farkl\u0131 okuma metotlar\u0131\n      if (this.isImage) {\n        reader.readAsDataURL(this.selectedFile);\n      } else if (this.isText) {\n        reader.readAsText(this.selectedFile, 'UTF-8');\n      } else {\n        \/\/ Desteklenmeyen di\u011fer t\u00fcrler i\u00e7in bir uyar\u0131 verebiliriz veya ArrayBuffer okuyabiliriz\n        this.errorMessage = 'Bu dosya t\u00fcr\u00fc i\u00e7in otomatik \u00f6nizleme desteklenmiyor. L\u00fctfen manuel olarak i\u015fleyin.';\n        this.isLoading = false;\n      }\n    },\n    resetState() {\n      this.selectedFile = null;\n      this.fileContent = null;\n      this.fileName = '';\n      this.fileSize = 0;\n      this.fileType = '';\n      this.errorMessage = '';\n      this.isLoading = false;\n      this.progress = 0;\n    },\n    formatBytes(bytes, decimals = 2) {\n      if (bytes === 0) return '0 Bytes';\n      const k = 1024;\n      const dm = decimals < 0 ? 0 : decimals;\n      const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n      const i = Math.floor(Math.log(bytes) \/ Math.log(k));\n      return parseFloat((bytes \/ Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];\n    }\n  }\n};\n<\/script><\/p>\n<style scoped>\n.file-reader-container {\n  max-width: 800px;\n  margin: 40px auto;\n  padding: 25px;\n  border: 1px solid #e0e0e0;\n  border-radius: 8px;\n  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);\n  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n  color: #333;\n  background-color: #fff;\n}<\/p>\n<p>h2 {\n  text-align: center;\n  color: #2c3e50;\n  margin-bottom: 30px;\n}<\/p>\n<p>h3 {\n  color: #34495e;\n  border-bottom: 1px solid #eee;\n  padding-bottom: 8px;\n  margin-top: 25px;\n  margin-bottom: 15px;\n}<\/p>\n<p>.file-input-section {\n  display: flex;\n  align-items: center;\n  gap: 15px;\n  margin-bottom: 20px;\n  padding: 15px;\n  background-color: #f9f9f9;\n  border: 1px dashed #ccc;\n  border-radius: 6px;\n}<\/p>\n<p>input[type=\"file\"] {\n  display: none; \/<em> Varsay\u0131lan dosya input'unu gizle <\/em>\/\n}<\/p>\n<p>.custom-file-upload {\n  display: inline-block;\n  padding: 10px 20px;\n  background-color: #007bff;\n  color: white;\n  border-radius: 5px;\n  cursor: pointer;\n  transition: background-color 0.3s ease;\n  font-weight: bold;\n}<\/p>\n<p>.custom-file-upload:hover {\n  background-color: #0056b3;\n}<\/p>\n<p>.selected-file-name {\n  font-style: italic;\n  color: #5cb85c;\n  font-weight: 500;\n}<\/p>\n<p>.no-file-selected {\n  color: #6c757d;\n}<\/p>\n<p>.error-message {\n  color: #dc3545;\n  background-color: #f8d7da;\n  border: 1px solid #f5c6cb;\n  padding: 10px 15px;\n  border-radius: 5px;\n  margin-bottom: 20px;\n  font-weight: 500;\n}<\/p>\n<p>.loading-indicator {\n  text-align: center;\n  margin-bottom: 20px;\n  color: #007bff;\n  font-weight: 500;\n}<\/p>\n<p>.progress-bar-container {\n  width: 100%;\n  background-color: #e9ecef;\n  border-radius: 5px;\n  overflow: hidden;\n  height: 10px;\n  margin-top: 10px;\n}<\/p>\n<p>.progress-bar {\n  height: 100%;\n  background-color: #28a745;\n  width: 0%;\n  border-radius: 5px;\n  transition: width 0.3s ease;\n}<\/p>\n<p>.file-info-section p {\n  margin-bottom: 8px;\n  line-height: 1.5;\n}<\/p>\n<p>.file-content-section {\n  margin-top: 30px;\n  border-top: 1px solid #eee;\n  padding-top: 20px;\n}<\/p>\n<p>.image-preview img {\n  max-width: 100%;\n  height: auto;\n  display: block;\n  margin: 15px auto;\n  border: 1px solid #ddd;\n  border-radius: 4px;\n  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n}<\/p>\n<p>.text-preview pre {\n  background-color: #f4f4f4;\n  border: 1px solid #ddd;\n  padding: 15px;\n  border-radius: 5px;\n  max-height: 300px;\n  overflow-y: auto;\n  white-space: pre-wrap; \/<em> Uzun sat\u0131rlar\u0131 otomatik sar <\/em>\/\n  word-wrap: break-word; \/<em> Kelimeleri b\u00f6lerek sar <\/em>\/\n  font-family: 'Consolas', 'Monaco', monospace;\n  font-size: 0.9em;\n  line-height: 1.4;\n  color: #444;\n}<\/p>\n<p>.unsupported-preview {\n  background-color: #fff3cd;\n  border: 1px solid #ffeeba;\n  padding: 15px;\n  border-radius: 5px;\n  color: #856404;\n  font-weight: 500;\n}\n<\/style>\n<p><\/code><\/p>\n<p>Bu bile\u015feni <code>src\/App.vue<\/code> dosyas\u0131nda kullanarak uygulaman\u0131z\u0131 test edebilirsiniz:<\/p>\n<pre><code class=\"language-vue\"><!-- src\/App.vue -->\n<template>\n  <div id=\"app\">\n    <FileReaderComponent \/>\n  <\/div>\n<\/template>\n\n<script>\nimport FileReaderComponent from '.\/components\/FileReaderComponent.vue';\n\nexport default {\n  name: 'App',\n  components: {\n    FileReaderComponent\n  }\n};\n<\/script>\n\n<style>\nbody {\n  margin: 0;\n  background-color: #f8f9fa;\n}\n#app {\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  color: #2c3e50;\n}\n<\/style><\/code><\/pre>\n<h2>FileReader API'nin Vue.js ile Entegrasyonu<\/h2>\n<p>Bile\u015fenimizin <code><script><\/code> b\u00f6l\u00fcm\u00fcnde <code>FileReader<\/code> API'sini Vue'nun reaktif veri sistemi ve metotlar\u0131 ile nas\u0131l entegre etti\u011fimizi inceleyelim.<\/p>\n<h3>Dosya Se\u00e7imi \u0130\u015fleme<\/h3>\n<p>Kullan\u0131c\u0131 bir dosya se\u00e7ti\u011finde, <code><input type=\"file\"><\/code> elementinin <code>@change<\/code> olay\u0131 <code>handleFileChange<\/code> metodumuzu tetikler.<\/p>\n<pre><code class=\"language-javascript\">\/\/ ... script b\u00f6l\u00fcm\u00fcnde\nmethods: {\n  handleFileChange(event) {\n    this.resetState(); \/\/ \u00d6nceki durumu temizle\n    const file = event.target.files[0]; \/\/ Se\u00e7ilen ilk dosyay\u0131 al\n\n    if (!file) {\n      this.errorMessage = 'Dosya se\u00e7ilmedi.';\n      return;\n    }\n\n    \/\/ Dosya boyutu kontrol\u00fc (\u00f6rne\u011fin, 5MB'dan b\u00fcy\u00fck olmas\u0131n)\n    const MAX_FILE_SIZE = 5 <em> 1024 <\/em> 1024; \/\/ 5 MB\n    if (file.size > MAX_FILE_SIZE) {\n      this.errorMessage = <code>Dosya boyutu ${this.formatBytes(file.size)} \u00e7ok b\u00fcy\u00fck. Maksimum ${this.formatBytes(MAX_FILE_SIZE)} olmal\u0131d\u0131r.<\/code>;\n      return;\n    }\n\n    this.selectedFile = file;\n    this.fileName = file.name;\n    this.fileSize = file.size;\n    this.fileType = file.type || 'Bilinmeyen Tip'; \/\/ type bo\u015f olabilir\n\n    this.readFile(); \/\/ Dosyay\u0131 okuma i\u015flemini ba\u015flat\n  },\n  \/\/ ... di\u011fer metotlar\n}<\/code><\/pre>\n<p>Bu metot, <code>event.target.files<\/code> dizisinden ilk dosyay\u0131 al\u0131r. E\u011fer dosya se\u00e7ilmemi\u015fse veya belirlenen maksimum boyutu a\u015f\u0131yorsa hata mesaj\u0131 g\u00f6sterir. Aksi takdirde, dosya bilgilerini bile\u015fenin veri \u00f6zelliklerine atar ve <code>readFile<\/code> metodunu \u00e7a\u011f\u0131rarak okuma i\u015flemini ba\u015flat\u0131r. <code>resetState<\/code> metodu, her yeni dosya se\u00e7iminde bile\u015fenin durumunu ba\u015flang\u0131\u00e7 haline getirir.<\/p>\n<h3>Dosya Okuma Mant\u0131\u011f\u0131<\/h3>\n<p><code>readFile<\/code> metodu, <code>FileReader<\/code> nesnesini olu\u015fturmaktan ve dosya okuma i\u015flemini y\u00f6netmekten sorumludur.<\/p>\n<pre><code class=\"language-javascript\">\/\/ ... script b\u00f6l\u00fcm\u00fcnde\nmethods: {\n  \/\/ ... handleFileChange metodu\n  readFile() {\n    this.isLoading = true; \/\/ Y\u00fckleme durumunu ba\u015flat\n    this.errorMessage = ''; \/\/ Hata mesaj\u0131n\u0131 temizle\n    this.fileContent = null; \/\/ \u00d6nceki i\u00e7eri\u011fi temizle\n    this.progress = 0; \/\/ \u0130lerleme \u00e7ubu\u011funu s\u0131f\u0131rla\n\n    const reader = new FileReader();\n\n    reader.onloadstart = () => {\n      this.progress = 0; \/\/ Okuma ba\u015flang\u0131c\u0131nda ilerlemeyi s\u0131f\u0131rla\n    };\n\n    reader.onprogress = (event) => {\n      if (event.lengthComputable) {\n        this.progress = Math.round((event.loaded \/ event.total) * 100); \/\/ \u0130lerleme y\u00fczdesini hesapla\n      }\n    };\n\n    reader.onload = (e) => {\n      this.fileContent = e.target.result; \/\/ Okunan i\u00e7eri\u011fi al\n      this.isLoading = false; \/\/ Y\u00fckleme tamamland\u0131\n      this.progress = 100; \/\/ \u0130lerleme \u00e7ubu\u011funu %100 yap\n    };\n\n    reader.onerror = (e) => {\n      this.errorMessage = 'Dosya okuma hatas\u0131: ' + e.target.error.message;\n      this.isLoading = false;\n      this.fileContent = null;\n    };\n\n    reader.onabort = () => {\n      this.errorMessage = 'Dosya okuma i\u015flemi iptal edildi.';\n      this.isLoading = false;\n      this.fileContent = null;\n    };\n\n    \/\/ Dosya tipine g\u00f6re farkl\u0131 okuma metotlar\u0131\n    if (this.isImage) {\n      reader.readAsDataURL(this.selectedFile); \/\/ Resimler i\u00e7in Base64 URL olarak oku\n    } else if (this.isText) {\n      reader.readAsText(this.selectedFile, 'UTF-8'); \/\/ Metin dosyalar\u0131 i\u00e7in metin olarak oku\n    } else {\n      \/\/ Desteklenmeyen di\u011fer t\u00fcrler i\u00e7in bir uyar\u0131 verebiliriz veya ArrayBuffer okuyabiliriz\n      this.errorMessage = 'Bu dosya t\u00fcr\u00fc i\u00e7in otomatik \u00f6nizleme desteklenmiyor. L\u00fctfen manuel olarak i\u015fleyin.';\n      this.isLoading = false;\n    }\n  },\n  resetState() { \/<em> ... <\/em>\/ },\n  formatBytes() { \/<em> ... <\/em>\/ }\n}<\/code><\/pre>\n<p>Bu <code>readFile<\/code> metodu a\u015fa\u011f\u0131daki ad\u0131mlar\u0131 ger\u00e7ekle\u015ftirir:<br \/>\n1.  <strong>Durum Y\u00f6netimi:<\/strong> <code>isLoading<\/code> bayra\u011f\u0131n\u0131 <code>true<\/code> yaparak y\u00fckleme g\u00f6stergesini etkinle\u015ftirir, hata mesaj\u0131n\u0131 ve \u00f6nceki dosya i\u00e7eri\u011fini temizler.<br \/>\n2.  <strong><code>FileReader<\/code> Olu\u015fturma:<\/strong> Yeni bir <code>FileReader<\/code> nesnesi (<code>reader<\/code>) olu\u015fturulur.<br \/>\n3.  <strong>Olay Dinleyicileri:<\/strong> <code>FileReader<\/code> nesnesinin <code>onloadstart<\/code>, <code>onprogress<\/code>, <code>onload<\/code>, <code>onerror<\/code> ve <code>onabort<\/code> olaylar\u0131na ilgili geri \u00e7a\u011f\u0131rma fonksiyonlar\u0131 atan\u0131r.<br \/>\n    *   <code>onloadstart<\/code> ve <code>onprogress<\/code>: Y\u00fckleme ilerlemesini <code>progress<\/code> veri \u00f6zelli\u011fine kaydeder.<br \/>\n    *   <code>onload<\/code>: Okuma i\u015flemi ba\u015far\u0131yla tamamland\u0131\u011f\u0131nda <code>e.target.result<\/code> ile dosya i\u00e7eri\u011fini al\u0131r ve <code>fileContent<\/code> veri \u00f6zelli\u011fine atar. <code>isLoading<\/code>'i <code>false<\/code> yapar.<br \/>\n    *   <code>onerror<\/code> ve <code>onabort<\/code>: Hata veya iptal durumunda <code>errorMessage<\/code>'\u0131 g\u00fcnceller ve <code>isLoading<\/code>'i <code>false<\/code> yapar.<br \/>\n4.  <strong>Dosya Tipine G\u00f6re Okuma:<\/strong> <code>isImage<\/code> ve <code>isText<\/code> hesaplanm\u0131\u015f \u00f6zellikleri (computed properties) kullanarak dosya tipini kontrol eder ve uygun <code>FileReader<\/code> metotunu (<code>readAsDataURL<\/code> veya <code>readAsText<\/code>) \u00e7a\u011f\u0131r\u0131r. Desteklenmeyen bir t\u00fcr i\u00e7in hata mesaj\u0131 g\u00f6sterir.<\/p>\n<h3>Hesaplanm\u0131\u015f \u00d6zellikler (Computed Properties)<\/h3>\n<p><code>formattedFileSize<\/code>, <code>isImage<\/code> ve <code>isText<\/code> gibi hesaplanm\u0131\u015f \u00f6zellikler, bile\u015fenin \u015fablonunda kullan\u0131lan verileri t\u00fcretmek veya formatlamak i\u00e7in kullan\u0131\u015fl\u0131d\u0131r.<\/p>\n<pre><code class=\"language-javascript\">\/\/ ... script b\u00f6l\u00fcm\u00fcnde\ncomputed: {\n  formattedFileSize() {\n    if (this.fileSize === 0) return '0 Bytes';\n    const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n    const i = parseInt(Math.floor(Math.log(this.fileSize) \/ Math.log(1024)));\n    return Math.round(this.fileSize \/ Math.pow(1024, i), 2) + ' ' + sizes[i];\n  },\n  isImage() {\n    return this.fileType.startsWith('image\/');\n  },\n  isText() {\n    return this.fileType.startsWith('text\/') ||\n           this.fileType === 'application\/json' ||\n           this.fileType === 'application\/csv';\n  }\n}<\/code><\/pre>\n<p>*   <code>formattedFileSize<\/code>: <code>fileSize<\/code> de\u011ferini okunabilir bir formatta (\u00f6rn. \"1.2 MB\") g\u00f6sterir.<br \/>\n*   <code>isImage<\/code>: Dosya tipinin bir resim olup olmad\u0131\u011f\u0131n\u0131 kontrol eder.<br \/>\n*   <code>isText<\/code>: Dosya tipinin metin tabanl\u0131 olup olmad\u0131\u011f\u0131n\u0131 kontrol eder.<\/p>\n<h2>Farkl\u0131 Dosya Tipleri ve Okuma Metotlar\u0131<\/h2>\n<p><code>FileReader<\/code> API'si, farkl\u0131 dosya t\u00fcrlerini i\u015flemek i\u00e7in \u00e7e\u015fitli okuma metotlar\u0131 sunar. Bile\u015fenimizde, en yayg\u0131n iki kullan\u0131m senaryosu olan metin ve g\u00f6rsel dosyalar\u0131n\u0131 ele ald\u0131k.<\/p>\n<h3>Metin Dosyalar\u0131 (.txt, .json, .csv)<\/h3>\n<p>Metin tabanl\u0131 dosyalar i\u00e7in <code>readAsText()<\/code> metodu kullan\u0131l\u0131r. Bu metot, dosyan\u0131n i\u00e7eri\u011fini bir metin dizesi olarak okur. <code>UTF-8<\/code> gibi bir karakter kodlamas\u0131 belirterek karakterlerin do\u011fru \u015fekilde g\u00f6r\u00fcnt\u00fclenmesini sa\u011flayabilirsiniz.<\/p>\n<pre><code class=\"language-javascript\">reader.readAsText(this.selectedFile, 'UTF-8');<\/code><\/pre>\n<p>Okunan i\u00e7erik do\u011frudan <code><\/p>\n<pre><\/code> etiketi i\u00e7inde g\u00f6r\u00fcnt\u00fclenebilir. <code><pre><\/code> etiketi, \u00f6nceden bi\u00e7imlendirilmi\u015f metni korudu\u011fu i\u00e7in kod veya d\u00fcz metin dosyalar\u0131 i\u00e7in idealdir.\n\n<h3>G\u00f6rsel Dosyalar\u0131 (.jpg, .png, .gif)<\/h3>\nResim dosyalar\u0131 i\u00e7in <code>readAsDataURL()<\/code> metodu kullan\u0131l\u0131r. Bu metot, dosyan\u0131n i\u00e7eri\u011fini Base64 kodlu bir veri URL'si olarak okur. Bu URL, do\u011frudan bir <code><img><\/code> etiketinin <code>src<\/code> \u00f6zniteli\u011finde kullan\u0131larak resmin \u00f6nizlemesini sa\u011flar.\n\n<pre><code class=\"language-javascript\">reader.readAsDataURL(this.selectedFile);<\/code><\/pre>\n<p>Vue \u015fablonunda <code>v-if=\"isImage\"<\/code> ile bu i\u00e7eri\u011fi bir <code><img><\/code> etiketi i\u00e7inde g\u00f6sterebiliriz.<\/p>\n<h3>\u0130kili Dosyalar (.pdf, .zip, ses\/video)<\/h3>\n<p>Daha karma\u015f\u0131k ikili dosya t\u00fcrleri (\u00f6rne\u011fin PDF'ler, ses veya video dosyalar\u0131) i\u00e7in <code>readAsArrayBuffer()<\/code> metodu kullan\u0131l\u0131r. Bu metot, dosyan\u0131n i\u00e7eri\u011fini bir <code>ArrayBuffer<\/code> olarak okur. <code>ArrayBuffer<\/code>, ham ikili veriyi temsil eden sabit uzunlukta bir veri arabelle\u011fidir. Bu t\u00fcr verileri do\u011frudan g\u00f6r\u00fcnt\u00fclemek yerine, genellikle PDF.js gibi \u00f6zel k\u00fct\u00fcphaneler veya Web Audio API gibi taray\u0131c\u0131 API'leri ile i\u015flenmesi gerekir.<\/p>\n<p>\u00d6rne\u011fin, bir PDF dosyas\u0131n\u0131 okumak i\u00e7in:<\/p>\n<pre><code class=\"language-javascript\">\/\/ readFile metodu i\u00e7inde\n\/\/ ...\n} else if (this.fileType === 'application\/pdf') {\n  reader.readAsArrayBuffer(this.selectedFile);\n} else {\n  \/\/ ...\n}\n\n\/\/ onload i\u00e7inde ArrayBuffer'\u0131 i\u015flemek i\u00e7in\nreader.onload = (e) => {\n  this.fileContent = e.target.result; \/\/ Bu bir ArrayBuffer olacakt\u0131r\n  this.isLoading = false;\n  this.progress = 100;\n\n  if (this.fileType === 'application\/pdf') {\n    \/\/ PDF.js veya benzeri bir k\u00fct\u00fcphane ile ArrayBuffer'\u0131 i\u015fleyebilirsiniz\n    console.log('PDF ArrayBuffer okundu:', this.fileContent);\n    \/\/ \u00d6rne\u011fin, PDF.js kullanarak bir tuval \u00fczerine render edilebilir.\n  }\n};<\/code><\/pre>\n<p>Bu makale kapsam\u0131nda, <code>ArrayBuffer<\/code> i\u015fleme derinlemesine ele al\u0131nmayacakt\u0131r, ancak bu metodun varl\u0131\u011f\u0131n\u0131 ve amac\u0131n\u0131 bilmek \u00f6nemlidir.<\/p>\n<h2>Geli\u015fmi\u015f Konular ve \u0130yile\u015ftirmeler<\/h2>\n<p>Olu\u015fturdu\u011fumuz temel bile\u015feni daha sa\u011flam ve kullan\u0131c\u0131 dostu hale getirmek i\u00e7in baz\u0131 geli\u015fmi\u015f konular\u0131 ve iyile\u015ftirmeleri d\u00fc\u015f\u00fcnebiliriz.<\/p>\n<h3>Hata Y\u00f6netimi<\/h3>\n<p><code>FileReader<\/code> API'sinin <code>onerror<\/code> olay\u0131, dosya okuma s\u0131ras\u0131nda meydana gelen hatalar\u0131 yakalamak i\u00e7in kritik \u00f6neme sahiptir. Bile\u015fenimizde, kullan\u0131c\u0131ya anlaml\u0131 hata mesajlar\u0131 g\u00f6stermek i\u00e7in bu olay\u0131 kulland\u0131k.<br \/>\nEk olarak, dosya boyutu veya t\u00fcr\u00fc gibi istemci taraf\u0131 do\u011frulama kontrolleri eklemek, gereksiz sunucu y\u00fck\u00fcn\u00fc azalt\u0131r ve kullan\u0131c\u0131 deneyimini iyile\u015ftirir. \u00d6rne\u011fin, <code>accept<\/code> niteli\u011fini kullanarak <code><input type=\"file\"><\/code> elementinde kabul edilen dosya t\u00fcrlerini k\u0131s\u0131tlayabilirsiniz.<\/p>\n<pre><code class=\"language-html\"><input\n  id=\"file-upload\"\n  type=\"file\"\n  @change=\"handleFileChange\"\n  accept=\".txt,.json,.csv,image\/*\" <!-- Yaln\u0131zca belirtilen t\u00fcrleri kabul et -->\n\/><\/code><\/pre>\n<p>Bu, kullan\u0131c\u0131n\u0131n yanl\u0131\u015f t\u00fcrde dosya se\u00e7mesini engellemeye yard\u0131mc\u0131 olur, ancak tam g\u00fcvenlik i\u00e7in her zaman sunucu taraf\u0131nda da do\u011frulama yapmal\u0131s\u0131n\u0131z.<\/p>\n<h3>Y\u00fckleme G\u00f6stergesi ve \u0130lerleme<\/h3>\n<p>B\u00fcy\u00fck dosyalar okunurken kullan\u0131c\u0131ya geri bildirim sa\u011flamak \u00f6nemlidir. <code>reader.onprogress<\/code> olay\u0131, dosya okuma ilerlemesini y\u00fczde olarak almak i\u00e7in kullan\u0131l\u0131r. Bu bilgiyi bir ilerleme \u00e7ubu\u011fu veya metin tabanl\u0131 bir g\u00f6sterge ile sunmak, kullan\u0131c\u0131 deneyimini \u00f6nemli \u00f6l\u00e7\u00fcde art\u0131r\u0131r. Bile\u015fenimizde <code>isLoading<\/code> ve <code>progress<\/code> veri \u00f6zelliklerini kullanarak bu geri bildirimi sa\u011flad\u0131k.<\/p>\n<h3>Birden Fazla Dosya Se\u00e7imi<\/h3>\n<p>E\u011fer uygulaman\u0131z\u0131n birden fazla dosya okumas\u0131n\u0131 istiyorsan\u0131z, <code><input type=\"file\"><\/code> elementine <code>multiple<\/code> niteli\u011fini eklemeniz yeterlidir:<\/p>\n<pre><code class=\"language-html\"><input type=\"file\" multiple @change=\"handleMultipleFileChange\"><\/code><\/pre>\n<p>Bu durumda, <code>event.target.files<\/code> bir <code>FileList<\/code> nesnesi olarak birden fazla dosya i\u00e7erecektir. Bu dosyalar\u0131 bir <code>for<\/code> d\u00f6ng\u00fcs\u00fc veya <code>Array.from()<\/code> ile bir diziye d\u00f6n\u00fc\u015ft\u00fcrerek her birini ayr\u0131 ayr\u0131 okuyabilirsiniz.<\/p>\n<pre><code class=\"language-javascript\">handleMultipleFileChange(event) {\n  this.resetState();\n  const files = Array.from(event.target.files);\n\n  if (files.length === 0) {\n    this.errorMessage = 'Dosya se\u00e7ilmedi.';\n    return;\n  }\n\n  files.forEach(file => {\n    \/\/ Her dosya i\u00e7in okuma mant\u0131\u011f\u0131n\u0131 \u00e7a\u011f\u0131r\u0131n\n    \/\/ Bu, her dosya i\u00e7in yeni bir FileReader nesnesi gerektirecektir.\n    \/\/ Veya dosyalar\u0131 bir diziye ekleyip, ayr\u0131 bir \"i\u015flem s\u0131ras\u0131\" mekanizmas\u0131 kurabilirsiniz.\n    console.log(<code>Dosya ad\u0131: ${file.name}, Boyutu: ${this.formatBytes(file.size)}<\/code>);\n    \/\/ Her dosya i\u00e7in ayr\u0131 bir okuma i\u015flemi ba\u015flatmak, karma\u015f\u0131k UI gerektirebilir.\n    \/\/ \u00d6rne\u011fin, her dosya i\u00e7in ayr\u0131 bir \u00f6nizleme alan\u0131.\n  });\n}<\/code><\/pre>\n<p>Birden fazla dosya okuma, genellikle her dosya i\u00e7in ayr\u0131 bir <code>FileReader<\/code> \u00f6rne\u011fi olu\u015fturmay\u0131 ve her birinin durumunu ba\u011f\u0131ms\u0131z olarak y\u00f6netmeyi gerektirir.<\/p>\n<h3>Performans \u0130pu\u00e7lar\u0131<\/h3>\n<p>\u00c7ok b\u00fcy\u00fck dosyalarla \u00e7al\u0131\u015f\u0131rken (\u00f6rne\u011fin, gigabaytlarca veri), <code>FileReader<\/code>'\u0131n <code>readAsText<\/code> veya <code>readAsDataURL<\/code> gibi metotlar\u0131n\u0131 do\u011frudan kullanmak bellek sorunlar\u0131na yol a\u00e7abilir. Bu senaryolarda:<br \/>\n*   <strong>Chunking (Par\u00e7alara Ay\u0131rma):<\/strong> Dosyay\u0131 k\u00fc\u00e7\u00fck par\u00e7alara (chunk) ay\u0131rarak ve her par\u00e7ay\u0131 ayr\u0131 ayr\u0131 okuyarak bellek kullan\u0131m\u0131n\u0131 optimize edebilirsiniz. Bu, <code>Blob.slice()<\/code> metodu ile yap\u0131labilir.<br \/>\n*   <strong>Web Workers:<\/strong> Yo\u011fun dosya i\u015fleme i\u015flemlerini ana UI i\u015f par\u00e7ac\u0131\u011f\u0131ndan ay\u0131rmak i\u00e7in Web Workers kullanmak, uygulaman\u0131z\u0131n duyarl\u0131l\u0131\u011f\u0131n\u0131 art\u0131rabilir.<\/p>\n<h3>G\u00fcvenlik Hususlar\u0131<\/h3>\n<p><code>FileReader<\/code> API'si istemci taraf\u0131nda \u00e7al\u0131\u015ft\u0131\u011f\u0131 i\u00e7in do\u011frudan bir g\u00fcvenlik riski olu\u015fturmaz. Ancak, okunan i\u00e7eri\u011fi do\u011frudan DOM'a enjekte ederken dikkatli olmak gerekir, \u00f6zellikle <code>v-html<\/code> direktifi kullan\u0131l\u0131yorsa. K\u00f6t\u00fc niyetli bir kullan\u0131c\u0131 taraf\u0131ndan y\u00fcklenen bir dosya, zararl\u0131 betikler i\u00e7erebilir ve bu betikler uygulaman\u0131zda \u00e7al\u0131\u015ft\u0131r\u0131labilir. Her zaman okunan i\u00e7eri\u011fi temizlemeli veya g\u00fcvenli bir \u015fekilde i\u015flemelisiniz. \u00d6rne\u011fin, resim \u00f6nizlemelerinde <code>src<\/code> \u00f6zniteli\u011fi i\u00e7in Base64 URL'leri kullanmak genellikle g\u00fcvenlidir, ancak metin i\u00e7eri\u011fini <code><\/p>\n<pre><\/code> etiketi d\u0131\u015f\u0131nda do\u011frudan <code>v-html<\/code> ile g\u00f6stermekten ka\u00e7\u0131nmal\u0131s\u0131n\u0131z.<\/p>\n<h2>Sonu\u00e7<\/h2>\n<p>Bu makalede, Vue.js ile <code>FileReader<\/code> API'sini kullanarak g\u00fc\u00e7l\u00fc ve esnek bir dosya okuyucu bile\u015feni olu\u015fturmay\u0131 \u00f6\u011frendik. <code>FileReader<\/code> API'sinin asenkron do\u011fas\u0131 ve Vue.js'in reaktif veri y\u00f6netimi yetenekleri sayesinde, kullan\u0131c\u0131lar\u0131n yerel sistemlerinden dosya se\u00e7melerini, i\u00e7eriklerini okumalar\u0131n\u0131 ve \u00f6nizlemelerini sa\u011flamak olduk\u00e7a basit hale gelmektedir.<\/p>\n<p>Olu\u015fturdu\u011fumuz bile\u015fen, metin ve g\u00f6rsel dosyalar\u0131 i\u00e7in temel \u00f6nizleme i\u015flevselli\u011fi sunarken, ilerleme g\u00f6stergesi, hata y\u00f6netimi ve dosya boyutu do\u011frulamas\u0131 gibi \u00f6nemli \u00f6zelliklerle de donat\u0131lm\u0131\u015ft\u0131r. <code>readAsArrayBuffer<\/code> gibi di\u011fer okuma metotlar\u0131n\u0131 kullanarak daha karma\u015f\u0131k ikili dosya t\u00fcrlerini (PDF, ses, video vb.) i\u015flemek i\u00e7in bile\u015feni geni\u015fletebilirsiniz.<\/p>\n<p><code>FileReader<\/code> API'si, web uygulamalar\u0131n\u0131z\u0131n dosya i\u015fleme yeteneklerini \u00f6nemli \u00f6l\u00e7\u00fcde art\u0131r\u0131r. Kullan\u0131c\u0131lar\u0131n resimleri \u00f6nizlemesini, CSV verilerini istemci taraf\u0131nda analiz etmesini veya yap\u0131land\u0131rma dosyalar\u0131n\u0131 okumas\u0131n\u0131 sa\u011flayarak, daha zengin ve etkile\u015fimli kullan\u0131c\u0131 deneyimleri sunabilirsiniz. Her zaman oldu\u011fu gibi, istemci taraf\u0131 dosya i\u015flemlerini sunucu taraf\u0131 do\u011frulamalar\u0131 ve g\u00fcvenlik en iyi uygulamalar\u0131yla birle\u015ftirmeyi unutmay\u0131n. Bu rehber, kendi Vue.js uygulamalar\u0131n\u0131zda dosya okuma i\u015flevselli\u011fini uygulaman\u0131z i\u00e7in sa\u011flam bir temel sa\u011flam\u0131\u015ft\u0131r.<\/body><\/p>\n","protected":false},"excerpt":{"rendered":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma\nGiri\u015f\nWeb uygulamalar\u0131 g\u00fcn\u00fcm\u00fczde sadece sunucu taraf\u0131nda i\u015flenen v","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_page_header_type":"","csco_page_load_nextpost":"","csco_page_subscribe_form":"","csco_page_contact_form":"","footnotes":""},"categories":[1402],"tags":[],"class_list":{"0":"post-30956","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-vue","7":"cs-entry","8":"cs-video-wrap"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.5 (Yoast SEO v25.3.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma - Kodlar\u0131n Gizemli D\u00fcnyas\u0131<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma\" \/>\n<meta property=\"og:description\" content=\"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma Giri\u015f Web uygulamalar\u0131 g\u00fcn\u00fcm\u00fczde sadece sunucu taraf\u0131nda i\u015flenen v\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/\" \/>\n<meta property=\"og:site_name\" content=\"Kodlar\u0131n Gizemli D\u00fcnyas\u0131\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-03T21:41:32+00:00\" \/>\n<meta name=\"author\" content=\"Fatih Soysal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fatih Soysal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/\"},\"author\":{\"name\":\"Fatih Soysal\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"headline\":\"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma\",\"datePublished\":\"2025-10-03T21:41:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/\"},\"wordCount\":2324,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"articleSection\":[\"Vue\"],\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/\",\"name\":\"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma - Kodlar\u0131n Gizemli D\u00fcnyas\u0131\",\"isPartOf\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\"},\"datePublished\":\"2025-10-03T21:41:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Anasayfa\",\"item\":\"https:\/\/fatihsoysal.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#website\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/\",\"name\":\"Fatihsoysal.com\",\"description\":\"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim\",\"publisher\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"tr\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1\",\"name\":\"Fatih Soysal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"contentUrl\":\"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png\",\"width\":512,\"height\":512,\"caption\":\"Fatih Soysal\"},\"logo\":{\"@id\":\"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/\"},\"description\":\"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.\",\"url\":\"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/","og_locale":"tr_TR","og_type":"article","og_title":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma","og_description":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma Giri\u015f Web uygulamalar\u0131 g\u00fcn\u00fcm\u00fczde sadece sunucu taraf\u0131nda i\u015flenen v","og_url":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/","og_site_name":"Kodlar\u0131n Gizemli D\u00fcnyas\u0131","article_published_time":"2025-10-03T21:41:32+00:00","author":"Fatih Soysal","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Fatih Soysal","Tahmini okuma s\u00fcresi":"14 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#article","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/"},"author":{"name":"Fatih Soysal","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"headline":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma","datePublished":"2025-10-03T21:41:32+00:00","mainEntityOfPage":{"@id":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/"},"wordCount":2324,"commentCount":0,"publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"articleSection":["Vue"],"inLanguage":"tr","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/fatihsoysal.com\/blog\/#organization"}},{"@type":"WebPage","@id":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/","url":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/","name":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma - Kodlar\u0131n Gizemli D\u00fcnyas\u0131","isPartOf":{"@id":"https:\/\/fatihsoysal.com\/blog\/#website"},"datePublished":"2025-10-03T21:41:32+00:00","breadcrumb":{"@id":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fatihsoysal.com\/blog\/vue-js-ile-filereader-api-kullanarak-bir-dosya-okuyucu-bileseni-olusturma\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Anasayfa","item":"https:\/\/fatihsoysal.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Vue.js ile FileReader API Kullanarak Bir Dosya Okuyucu Bile\u015feni Olu\u015fturma"}]},{"@type":"WebSite","@id":"https:\/\/fatihsoysal.com\/blog\/#website","url":"https:\/\/fatihsoysal.com\/blog\/","name":"Fatihsoysal.com","description":"Blog - Yaz\u0131l\u0131m D\u00fcnyas\u0131 Tecr\u00fcbelerim","publisher":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fatihsoysal.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"tr"},{"@type":["Person","Organization"],"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/002a254750921dcfd568a99e48240dd1","name":"Fatih Soysal","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","contentUrl":"https:\/\/fatihsoysal.com\/blog\/wp-content\/uploads\/2024\/04\/cropped-replicate-prediction-3kgg1hgjn5rgp0cf0p5tr0jw7w-1.png","width":512,"height":512,"caption":"Fatih Soysal"},"logo":{"@id":"https:\/\/fatihsoysal.com\/blog\/#\/schema\/person\/image\/"},"description":"Kullan\u0131m ve kodlama m\u00fckemmeliyetini odak alan uygulamalar olu\u015fturma deneyimine sahip, profesyonel olarak 15+ y\u0131l \u00fczeri deneyime sahip bir yaz\u0131l\u0131m m\u00fchendisi.","url":"https:\/\/fatihsoysal.com\/blog\/author\/fatihsoysal\/"}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/30956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/comments?post=30956"}],"version-history":[{"count":1,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/30956\/revisions"}],"predecessor-version":[{"id":30957,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/posts\/30956\/revisions\/30957"}],"wp:attachment":[{"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/media?parent=30956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/categories?post=30956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fatihsoysal.com\/blog\/wp-json\/wp\/v2\/tags?post=30956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}