# Howto Decode64 attachment

**URL:** <https://discuss.elastic.co/t/howto-decode64-attachment/9992>\
**Category:** Elasticsearch\
**Created:** [December 7, 2012, 5:40pm UTC](https://discuss.elastic.co/t/howto-decode64-attachment/9992 "2012-12-07T17:40:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dukr](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@dukr](https://discuss.elastic.co/u/dukr)\
**Post date:** [December 7, 2012, 5:40pm UTC](https://discuss.elastic.co/t/howto-decode64-attachment/9992/1 "2012-12-07T17:40:13Z")

</div>

Hi,  
I would elasticserach used for indexing text files (PDF, DOC, XML), as well  
as their data storage. I used the example given on the web page for saving  
the file in base64 using the plugin to store/index in to elasticsearch. It  
works 🙂 .  
When I want to get the contents of the file in its original format (eg PDF)  
and get base64 string that is not properly structured (one long line). Is  
there any way how to get the original file (convert back into origin MIME  
type) from elasticsearch?

Thanks,  
DK

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 7, 2012, 6:57pm UTC](https://discuss.elastic.co/t/howto-decode64-attachment/9992/2 "2012-12-07T18:57:41Z")

</div>

Exactly what we do in [www.scrutmydocs.org](http://www.scrutmydocs.org) project.  
It's on Github.

That said, you are probably using mapper attachment plugin, aren't you?

So, I think that there is an issue (and I tried to fix it but did not manage to get my unit tests pass): content-type is not automaticaly set, so you have to manage it on your side.  
See: [scrutmydocs/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java at master · scrutmydocs/scrutmydocs · GitHub](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java)

When sending back the attachment to the user, you have to manage it again.  
See [scrutmydocs/src/main/java/org/scrutmydocs/webapp/servlet/DownloadServlet.java at master · scrutmydocs/scrutmydocs · GitHub](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/servlet/DownloadServlet.java)

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 7 déc. 2012 à 18:40, dukr [dusan.krasa@gmail.com](mailto:dusan.krasa@gmail.com) a écrit :

> Hi,  
> I would elasticserach used for indexing text files (PDF, DOC, XML), as well as their data storage. I used the example given on the web page for saving the file in base64 using the plugin to store/index in to elasticsearch. It works 🙂 .  
> When I want to get the contents of the file in its original format (eg PDF) and get base64 string that is not properly structured (one long line). Is there any way how to get the original file (convert back into origin MIME type) from elasticsearch?
> 
> ## Thanks, DK

--

---

<div class="post-metadata">

**Author:** ![dukr](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@dukr](https://discuss.elastic.co/u/dukr)\
**Post date:** [December 10, 2012, 12:31pm UTC](https://discuss.elastic.co/t/howto-decode64-attachment/9992/3 "2012-12-10T12:31:57Z")

</div>

Exactly the [www.scrutmydocs.org](http://www.scrutmydocs.org) looks like my project. 🙂

Yes, I used the mapper attachment plugin for first test.

Could you please give aditional info about the parameters in

> <https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java>

("\_content\_type") - it's MIME-TYPE ?  
("\_name") -it's filename  
("content") - it's base64 encoded document ?

## Thanks

dk

Dne pátek, 7. prosince 2012 19:57:41 UTC+1 David Pilato napsal(a):

> Exactly what we do in [www.scrutmydocs.org](http://www.scrutmydocs.org) project.  
> It's on Github.
> 
> That said, you are probably using mapper attachment plugin, aren't you?
> 
> So, I think that there is an issue (and I tried to fix it but did not  
> manage to get my unit tests pass): content-type is not automaticaly set, so  
> you have to manage it on your side.  
> See:  
> [scrutmydocs/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java at master · scrutmydocs/scrutmydocs · GitHub](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java)
> 
> When sending back the attachment to the user, you have to manage it again.  
> See  
> [scrutmydocs/src/main/java/org/scrutmydocs/webapp/servlet/DownloadServlet.java at master · scrutmydocs/scrutmydocs · GitHub](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/servlet/DownloadServlet.java)
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 7 déc. 2012 à 18:40, dukr \<[dusan...@gmail.com](mailto:dusan...@gmail.com) \<javascript:\>\> a écrit :
> 
> Hi,  
> I would elasticserach used for indexing text files (PDF, DOC, XML), as  
> well as their data storage. I used the example given on the web page for  
> saving the file in base64 using the plugin to store/index in to  
> elasticsearch. It works 🙂 .  
> When I want to get the contents of the file in its original format (eg  
> PDF) and get base64 string that is not properly structured (one long  
> line). Is there any way how to get the original file (convert back into  
> origin MIME type) from elasticsearch?
> 
> Thanks,  
> DK
> 
> --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 10, 2012, 12:35pm UTC](https://discuss.elastic.co/t/howto-decode64-attachment/9992/4 "2012-12-10T12:35:00Z")

</div>

Yes for all questions.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 10 déc. 2012 à 13:31, dukr [dusan.krasa@gmail.com](mailto:dusan.krasa@gmail.com) a écrit :

> Exactly the [www.scrutmydocs.org](http://www.scrutmydocs.org) looks like my project. 🙂
> 
> Yes, I used the mapper attachment plugin for first test.
> 
> Could you please give aditional info about the parameters in  
> [https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java)
> 
> ("\_content\_type") - it's MIME-TYPE ?  
> ("\_name") -it's filename  
> ("content") - it's base64 encoded document ?
> 
> ## Thanks
> 
> dk
> 
> Dne pátek, 7. prosince 2012 19:57:41 UTC+1 David Pilato napsal(a):  
> Exactly what we do in [www.scrutmydocs.org](http://www.scrutmydocs.org) project.  
> It's on Github.
> 
> That said, you are probably using mapper attachment plugin, aren't you?
> 
> So, I think that there is an issue (and I tried to fix it but did not manage to get my unit tests pass): content-type is not automaticaly set, so you have to manage it on your side.  
> See: [https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/service/document/DocumentService.java)
> 
> When sending back the attachment to the user, you have to manage it again.  
> See [https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/servlet/DownloadServlet.java](https://github.com/scrutmydocs/scrutmydocs/blob/master/src/main/java/org/scrutmydocs/webapp/servlet/DownloadServlet.java)
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 7 déc. 2012 à 18:40, dukr [dusan...@gmail.com](mailto:dusan...@gmail.com) a écrit :
> 
> > Hi,  
> > I would elasticserach used for indexing text files (PDF, DOC, XML), as well as their data storage. I used the example given on the web page for saving the file in base64 using the plugin to store/index in to elasticsearch. It works 🙂 .  
> > When I want to get the contents of the file in its original format (eg PDF) and get base64 string that is not properly structured (one long line). Is there any way how to get the original file (convert back into origin MIME type) from elasticsearch?
> > 
> > ## Thanks, DK
> 
> --

--

---

<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:** [July 6, 2017, 3:00am UTC](https://discuss.elastic.co/t/howto-decode64-attachment/9992/5 "2017-07-06T03:00:35Z")

</div>


