You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 4-binary/03-blob/article.md
+41-41Lines changed: 41 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -116,87 +116,87 @@ Ancak tıklanabilir bir HTML linki bulunan önceki örnekte `URL.revokeObjectURL
116
116
117
117
## Blob'tan base64'e
118
118
119
-
An alternative to `URL.createObjectURL` is to convert a blob into a base64-encoded string.
119
+
`URL.createObjectURL`'a bir alternatif de blob'u base64 olarak kodlanmış bir karakter dizisine dönüştürmek.
120
120
121
-
That encoding represents binary data as a string of ultra-safe "readable" characters with ASCII-codes from 0 to 64. And what's more important -- we can use this encoding in "data-urls".
121
+
Bu kodlama, ikili veriyi oldukça güvenilir şekilde 0'dan 64'e ASCII kodlarından oluşan "okunabilir" karakterlerle temsil eder ve daha da önemlisi bu kodlamayı "veri URL'leri" içinde kullanabiliriz.
122
122
123
-
A [data url](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs)has the form `data:[<mediatype>][;base64],<data>`. We can use such urls everywhere, on par with "regular" urls.
123
+
Bir [veri URL'i](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs)`data:[<mediatype>][;base64],<data>` formundadır. Bu tür URL'leri sıradan URL'lerle birebir aynı şekilde her yerde kullanabiliriz.
The browser will decode the string and show the image: <imgsrc="data:image/png;base64,R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMlWLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7">
131
+
Tarayıcı bu karakter dizisini çözecek ve resmi gösterecek: <imgsrc="data:image/png;base64,R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMlWLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7">
132
132
133
133
134
-
To transform a blob into base64, we'll use the built-in `FileReader`object. It can read data from Blobs in multiple formats. In the [next chapter](info:file)we'll cover it more in-depth.
134
+
Blob'u base64'e çevirmek için `FileReader`yerleşik objesini kullanacağız. Bu, blob'lardan birçok formatta veri okuyabilmekte. [bir sonraki bölümde](info:file)bunu daha derinlemesine ele alacağız.
135
135
136
-
Here's the demo of downloading a blob, now via base-64:
136
+
Aşağıdaki bir blob indirmenin şimdi base64 ile olan bir demosu:
137
137
138
138
```js run
139
139
let link =document.createElement('a');
140
-
link.download='hello.txt';
140
+
link.download='merhaba.txt';
141
141
142
-
let blob =newBlob(['Hello, world!'], {type:'text/plain'});
142
+
let blob =newBlob(['Merhaba Dünya'], {type:'text/plain'});
143
143
144
144
*!*
145
145
let reader =newFileReader();
146
-
reader.readAsDataURL(blob); //converts the blob to base64 and calls onload
146
+
reader.readAsDataURL(blob); // blob'u base64'e çevirir ve onload'ı çağırır
147
147
*/!*
148
148
149
149
reader.onload=function() {
150
-
link.href=reader.result; //data url
150
+
link.href=reader.result; //veri URL'i
151
151
link.click();
152
152
};
153
153
```
154
154
155
-
Both ways of making an URL of a blob are usable. But usually `URL.createObjectURL(blob)`is simpler and faster.
155
+
Bir blog oluşturmanın bu iki yolu da kullanılabilir ancak genellikle `URL.createObjectURL(blob)`daha basit ve hızlıdır.
156
156
157
-
```compare title-plus="URL.createObjectURL(blob)" title-minus="Blob to data url"
158
-
+ We need to revoke them if care about memory.
159
-
+ Direct access to blob, no "encoding/decoding"
160
-
- No need to revoke anything.
161
-
- Performance and memory losses on big blobs for encoding.
157
+
```compare title-plus="URL.createObjectURL(blob)" title-minus="Blob'tan veri URL'i"
158
+
+ Hafızaya önem veriyorsak kaldırmamız gerekiyor..
159
+
+ Blob'a doğrudan erişim. "Kodlama/çözme" yok.
160
+
- Herhangi bir şey kaldırmamız gerekmiyor.
161
+
- Performans ve hafıza büyük blob'ların kodlanması için harcanır.
162
162
```
163
163
164
-
## Image to blob
164
+
## Resim'den blob'a
165
165
166
-
We can create a blob of an image, an image part, or even make a page screenshot. That's handy to upload it somewhere.
166
+
Bir resmin blob'unu oluşturabiliriz, bir resim parçası olabilir veya sayfanın ekran görüntüsünü dahi oluşturabiliriz. Bir yerlere yükleme yapmak için oldukça kullanışlı.
167
167
168
-
Image operations are done via `<canvas>`element:
168
+
Resim işlemleri `<canvas>`öğesi aracılığıyla yapılır:
169
169
170
-
1.Draw an image (or its part) on canvas using [canvas.drawImage](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage).
171
-
2.Call canvas method [.toBlob(callback, format, quality)](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)that creates a blob and runs `callback` with it when done.
170
+
1.Canvas üzerinde [canvas.drawImage](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage) kullanarak bir resim çiz (veya bir parçasını).
171
+
2.Canvas'ın bir blob oluşturan ve tamamlandığında `callback`ini çalıştıran [.toBlob(callback, format, quality)](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)metodunu çağır.
172
172
173
-
In the example below, an image is just copied, but we could cut from it, or transform it on canvas prior to making a blob:
173
+
Aşağıdaki örnekte resim henüz kopyalanmış ancak bu durumda onu kesebiliriz veya bir blob oluşturmadan önce dönüştürebiliriz:
174
174
175
175
```js run
176
-
//take any image
176
+
//bir resim al
177
177
let img =document.querySelector('img');
178
178
179
-
//make <canvas> of the same size
179
+
//aynı boyutlarda <canvas> oluştur
180
180
let canvas =document.createElement('canvas');
181
181
canvas.width=img.clientWidth;
182
182
canvas.height=img.clientHeight;
183
183
184
184
let context =canvas.getContext('2d');
185
185
186
-
//copy image to it (this method allows to cut image)
186
+
//resmi içine kopyala (bu metot resmi kesmeye izin verir)
187
187
context.drawImage(img, 0, 0);
188
-
//we can context.rotate(), and do many other things on canvas
188
+
// context.rotate() yapabiliriz ve canvas üzerinde birçok başka işlemde bulunabiliriz
189
189
190
-
// toBlob is async opereation, callback is called when done
190
+
// toBlob asenkron bir işlem, tamamlandığında callback çağırılacak
191
191
canvas.toBlob(function(blob) {
192
-
// blob ready, download it
192
+
// blob hazır, indir
193
193
let link =document.createElement('a');
194
194
link.download='example.png';
195
195
196
196
link.href=URL.createObjectURL(blob);
197
197
link.click();
198
198
199
-
//delete the internal blob reference, to let the browser clear memory from it
199
+
//tarayıcının hafızadan temizleyebilmesi için iç blob referansını sil
200
200
URL.revokeObjectURL(link.href);
201
201
}, 'image/png');
202
202
```
@@ -208,14 +208,14 @@ let blob = await new Promise(resolve => canvasElem.toBlob(resolve, 'image/png'))
208
208
209
209
For screenshotting a page, we can use a library such as <https://github.com/niklasvh/html2canvas>. What it does is just walks the page and draws it on `<canvas>`. Then we can get a blob of it the same way as above.
210
210
211
-
## From Blob to ArrayBuffer
211
+
## Blob'tan ArrayBuffer'a
212
212
213
-
The `Blob`constructor allows to create a blob from almost anything, including any `BufferSource`.
213
+
`Blob`kurucu metodu, herhangi bir `BufferSource` içeren neredeyse her şeyden bir blob yaratabilmeye olanak sağlar.
214
214
215
-
But if we need to perform low-level processing, we can get the lowest-level`ArrayBuffer` from it using `FileReader`:
215
+
Yine de düşük seviye bir işleme ihtiyacımız varsa `FileReader`ı kullanarak en düşük seviyeli`ArrayBuffer`ı alabiliriz:
While `ArrayBuffer`, `Uint8Array`and other`BufferSource` are "binary data", a[Blob](https://www.w3.org/TR/FileAPI/#dfn-Blob)represents "binary data with type".
233
+
`ArrayBuffer`, `Uint8Array`ve diğer`BufferSource`lar "ikili veri"ler iken[Blob](https://www.w3.org/TR/FileAPI/#dfn-Blob)"tipi olan ikili veri"yi temsil eder.
234
234
235
-
That makes Blobs convenient for upload/download operations, that are so common in the browser.
235
+
Bu, Blob'ları tarayıcıda çok yaygın olan indirme/yükleme işlemleri için uygun hale getirir.
236
236
237
-
Methods that perform web-requests, such as [XMLHttpRequest](info:xmlhttprequest), [fetch](info:fetch-basics)and so on, can work with `Blob`natively, as well as with other binary types.
237
+
[XMLHttpRequest](info:xmlhttprequest), [fetch](info:fetch-basics)gibi web isteği gerçekleştiren metotlar, diğer ikili verilerle olduğu gibi `Blob`ile de doğal olarak çalışabilir.
238
238
239
-
We can easily convert betweeen `Blob` and low-level binary data types:
239
+
`Blob` ve düşük seviye ikili veri tiplerini kolayca birbiri arasında dönüştürebiliriz:
240
240
241
-
-We can make a Blob from a typed array using `new Blob(...)`constructor.
242
-
-We can get back `ArrayBuffer` from a Blob using `FileReader`, and then create a view over it for low-level binary processing.
241
+
-`new Blob(...)`kurucu metodunu kullanarak tipli bir diziden bir blob oluşturabiliriz.
242
+
-Blob'tan `ArrayBuffer`a `FileReader` kullanarak dönebiliriz ve ardından düşük seviye ikili veri işleme işlemleri için bir view oluşturabiliriz.
0 commit comments