# How to encode file with base 64

**URL:** https://discuss.elastic.co/t/how-to-encode-file-with-base-64/126528
**Category:** Logstash
**Created:** [April 3, 2018, 8:48am UTC](https://discuss.elastic.co/t/how-to-encode-file-with-base-64/126528 "2018-04-03T08:48:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Yimjunhyeok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yimjunhyeok/32/19052_2.png) [@Yimjunhyeok](https://discuss.elastic.co/u/Yimjunhyeok)
#### Post date: [April 3, 2018, 8:48am UTC](https://discuss.elastic.co/t/how-to-encode-file-with-base-64/126528/1 "2018-04-03T08:48:29Z")

</div>

Hello. I want to save the file that is encoded in elasticsearch

So i use the logstash and ruby filter.

How to encode the content with ruby filter?

help me if you know this.

Below is my test..

13 filter {  
14 grok  
15 {  
16 match =\> ["message", %{WORD:b64}]  
17 }  
18 ruby  
19 {  
20 code =\> "event.set(@message, base64.strict\_encode64(b64))"  
21 }  
22 }

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 1, 2018, 8:48am UTC](https://discuss.elastic.co/t/how-to-encode-file-with-base-64/126528/2 "2018-05-01T08:48:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
