Splunk Dev

how to use splunk appserver receive and save files

hellosplunkit
Loves-to-Learn

Hi Splunker,

Today, I refer to this link https://wiki.splunk.com/Community:40GUIDevelopment  to develop the interface. I use the python library requests to upload the file, and use the CherryPy of Splunk to receive the file. But I can't receive and save the file. I printed the parameter content, but I didn't receive any parameter. Here is my code。

 

I use the python library requests to upload the file

 

 

    def forwardFile(self, filePath, fileName, url):
        files = {'ufile': open(os.path.join(filePath, fileName), 'rb')}
        data = {'xxx':'aaa','xxdd':'bbb'}
        headers = {}
        headers["content-type"] = 'multipart/form-data'
        r = requests.post(url, files=files,data=data ,headers=headers, verify=False)
        logger.info(r)

 

 

use the CherryPy of Splunk to receive the file

 

 

    @route('/:action=receive')
    @expose_page(must_login=False, methods=['GET','POST'])
    @cherrypy.expose
    def receive(self, **kwargs):
        logger.info("111")
        logger.info(kwargs)
        logger.info("222")

 

 

then i see the file web_service.log 

 

 

2020-10-15 23:21:07,472 INFO	[5f8868e36d107834250] <string>:68 - hello world:http://127.0.0.1
2020-10-15 23:21:07,501 INFO	[5f8868e37f107d00ad0] <string>:145 - 111
2020-10-15 23:21:07,501 INFO	[5f8868e37f107d00ad0] <string>:146 - {'action': 'receive'}
2020-10-15 23:21:07,501 INFO	[5f8868e37f107d00ad0] <string>:147 - 222
2020-10-15 23:21:07,507 INFO	[5f8868e36d107834250] <string>:79 - <Response [200]>

 

 

How to get the value of ufile ?

then i can save it.

Labels (1)
0 Karma

feelcool
Explorer

hello,hellosplunkit  

I have the same problem. Have you solved the problem yet??

0 Karma

richgalloway
SplunkTrust
SplunkTrust

That wiki page is very old (4 major versions!) so I would be very careful about using anything you read there.  CherryPy is deprecated in Splunk 8 so that's another reason to try a different approach.

Please describe what you want to accomplish and perhaps someone will have a modern way to do it.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...