# How to store a file to elastic search from kibana plugin server

**URL:** <https://discuss.elastic.co/t/how-to-store-a-file-to-elastic-search-from-kibana-plugin-server/228969>\
**Category:** Kibana\
**Created:** [April 21, 2020, 6:02am UTC](https://discuss.elastic.co/t/how-to-store-a-file-to-elastic-search-from-kibana-plugin-server/228969 "2020-04-21T06:02:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorioued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dorioued/32/46087_2.png) [@dorioued](https://discuss.elastic.co/u/dorioued)\
**Post date:** [April 21, 2020, 6:02am UTC](https://discuss.elastic.co/t/how-to-store-a-file-to-elastic-search-from-kibana-plugin-server/228969/1 "2020-04-21T06:02:10Z")

</div>

Hi Team,  
I am developing a kibana plugin that generate a file containing the data selected by the user on the plugin interface. After that I should be able to generate a link that the user can use to download the created file . Now I am at a point where I need to store the file and I was thinking of storing it in elastic search and provide the link for downloads. How can I do that from my kibana server ?  
Also how can I talk to elastic search om my server?  
I am making APIs call to the static host [http://localhost:9200/](http://localhost:9200/).  
But I wanna do it dynamically since it will be a plugin and the elastic search host my differs from one user to another.  
Thanks

---

<div class="post-metadata">

**Author:** ![myasonik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myasonik/32/62369_2.png) [@myasonik](https://discuss.elastic.co/u/myasonik)\
**Post date:** [April 22, 2020, 12:02am UTC](https://discuss.elastic.co/t/how-to-store-a-file-to-elastic-search-from-kibana-plugin-server/228969/2 "2020-04-22T00:02:32Z")

</div>

What sort of file are you creating and do you want them to be indexed an analyzed?

Generally, I'd probably recommend against storing big binary files in ES though you _can_ using something like the [ingest-attachment plugin](https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html)

If you're not creating a binary file, ES can handle that a little better. You can throw whatever you want into a JSON string as long as you escape. You'll probably want to set it to [text](https://www.elastic.co/guide/en/elasticsearch/reference/current/text.html)... If you don't want it to be searchable you can also set `index` to `false`.

All that said, not knowing your exact use case, I'd probably recommend storing the file somewhere else and storing the URL in ES.

---

<div class="post-metadata">

**Author:** ![dorioued](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dorioued/32/46087_2.png) [@dorioued](https://discuss.elastic.co/u/dorioued)\
**Post date:** [April 23, 2020, 8:01am UTC](https://discuss.elastic.co/t/how-to-store-a-file-to-elastic-search-from-kibana-plugin-server/228969/3 "2020-04-23T08:01:32Z")

</div>

I am creating a csv file. I guess the size of the file won't be that big, just few MB and I would keep that in elastic search if it's possible.

No I don't want them to be indexed.

Btw any idea on how to communicate with elastic search from my plugin server dynamically without using the static url [http://localhost:9200/](http://localhost:9200/). ? Because the ES url could change and not always be [http://localhost:9200/](http://localhost:9200/).

---

<div class="post-metadata">

**Author:** ![myasonik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/myasonik/32/62369_2.png) [@myasonik](https://discuss.elastic.co/u/myasonik)\
**Post date:** [April 23, 2020, 3:21pm UTC](https://discuss.elastic.co/t/how-to-store-a-file-to-elastic-search-from-kibana-plugin-server/228969/4 "2020-04-23T15:21:21Z")

</div>

> [@dorioued](#):
>
> Btw any idea on how to communicate with Elasticsearch from my plugin server dynamically without using the static url [http://localhost:9200/](http://localhost:9200/). ? Because the ES url could change and not always be [http://localhost:9200/](http://localhost:9200/).

You'll need something to tell you where ES lives... If you're sure it's only going to be on localhost, I guess you could also just start iterating through every port until you get a successful response.

---

<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 21, 2020, 3:31pm UTC](https://discuss.elastic.co/t/how-to-store-a-file-to-elastic-search-from-kibana-plugin-server/228969/5 "2020-05-21T15:31:49Z")

</div>

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