How to call fscrawler in an app web (python)?

Hello everybody, this is my first topic on this forum :slight_smile:

I would like if it was possible to use fscrawler on an app python. In fact, i created a simple interface to communicate with my ES cluster with flask, and it works pretty well.

But i would like create a section to upload new files, at the moment, i still use Kibana console or curl to upload them manually, i would like automatisize this process.

First i was using ingest-attachment plugin, but it does not work with file path, then i just convert manually my file in base64 (with copy-paste) and with PUT it in my index.

Then i discover fscraler, it works with file path; now i want to create a simple button with a function which do exactly same.

Should i create shell script to simply do the command ? Or any idea ? I searched solutions on community forum and i did not find what i wanted, si i ask by myself.

Thanks, and have a good day :slight_smile:

That's one of the reasons I added a Rest interface to FSCrawler project so you can just upload a binary file to FSCrawler service.

Then it's "just" a Rest call in python. I'm not a python developer so I can't tell more but that should be easy.

Hello dadoonet, thanks for answer :slight_smile: I will check it, thanks a lot

I solved my problem by the way, i will say here what happened, maybe it will help someone

In my app, i had to get my file with javascript and a simple function:

function MyFunction(){
var myFile = document.getElementById('fileInput').files[0];

}

with fileInput the id of upload form:

<input type="file" name="fileInput" id="fileInput" onchange="myFunction()" >

then there is the python part:

first of all i had to get my file object:

f = request.files['fileInput']

but it is fileObject so we have to "reflow" it:

sendFile = {"file": (f.filename, f.stream, f.mimetype)}

If we don't, we could not post it.

Finally i use a function from requests library:

r = requests.post(url, files=sendFile)

I hope it will help some people :slight_smile:

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