Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:33:57+00:00 2026-06-17T04:33:57+00:00

I am using Bottle for uploading rather large files. The idea is that when

  • 0

I am using Bottle for uploading rather large files. The idea is that when the file is uploaded, the web app run (and forget) a system command with the uploaded file-path as an argument. Except for starting the system command with the correct file-path as an argument I do not need to save the file, but I need to be certain that the file will be available until the process completes the processing.

I use the exact code described here:
http://bottlepy.org/docs/dev/tutorial.html#post-form-data-and-file-uploads

My questions are:

  • Do bottle store uploaded file in memory or on a specific place on the disk (or perhaps like Flask, a bit of both)?
  • Will the uploaded file be directly available to other tools without .read() and then manually saving the bytes to a specified file on disk?
  • What would be the best way to start the system command with the file as an argument? Is it possible to just pass the path to an existing file directly?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:33:58+00:00Added an answer on June 17, 2026 at 4:33 am

    Ok, let’s break this down.

    The full code is:

    HTML:

    <form action="/upload" method="post" enctype="multipart/form-data">
      <input type="text" name="name" />
      <input type="file" name="data" />
    </form>
    

    PYTHON CODE:

    from bottle import route, request
    @route('/upload', method='POST')
    def do_upload():
        name = request.forms.name
        data = request.files.data
        if name and data and data.file:
            raw = data.file.read() # This is dangerous for big files
            filename = data.filename
            return "Hello %s! You uploaded %s (%d bytes)." % (name, filename, len(raw))
        return "You missed a field."
    

    (From the doc’s you provided)

    So, first of all, we can see that we first pull the information from the name and the data in the html form, and assign them to the variables name and data. Thats pretty straight forward. However, next we assign the variable raw to data.file.read(). This is basically taking all of the file uploaded into the variable raw. This being said, the entire file is in memory, which is why they put "This is dangerous for big files" as a comment next to the line.

    This being said, if you wanted to save the file out to disk, you could do so (but be careful) using something like:

    with open(filename,'w') as open_file:
        open_file.write(data.file.read())
    

    As for your other questions:

    1."What would be the best way to start the system command with the file as an argument? Is it possible to just pass the path to an existing file directly?"

    You should see the subprocess module, specifically Popen: http://docs.python.org/2/library/subprocess.html#popen-constructor

    2."Will the uploaded file be directly available to other tools without .read() and then manually saving the bytes to a specified file on disk?"

    Yes, you can pass the file data around without saving it to disk, however, be warned that memory consumption is something to watch. However, if these "tools" are not in python, you may be dealing with pipes or subprocesses to pass the data to these "tools".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a python newbie and starting out with using the Bottle web framework on
As a learning project, I'm using MongoDB with Bottle for a web service. What
I'm running the micro framework Bottle on Google App Engine. I'm using Jinja2 for
I've got a problem with bottle, the _initialize function is run twice. Example app:
I am serving a test file through apache using Bottle. Following are my apache
I'm currently developing a bottle app within virtualenv. I intend to serve it using
I'm trying to display a page of html using bottle (the python web framework).
I'm trying to write a third party app of Sina Weibo using bottle. However,
I am using Bottle as a web server and need to pass a python
I am developing a very simple web application in python using the bottle microframework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.