Reputation: 12117
(Disclaimer: I'm discovering python)
With the following code:
@route('/test', method='POST')
def index_view():
image = request.files.get('image')
img = io.imread(image.file)
I am wondering how the files are managed: If several users are sending files with the same name (let's say a.jpg) at the same time, is there a chance that bottle saves 2 files 'a.jpg' and one overwrites the other?
If so, what would be the strategy to isolate files being sent from having a name collision?
Upvotes: 1
Views: 178
Reputation: 459
EDIT turns out your full code doesnt even write to disk, so there is no overwriting of any files
Actually bottle has a mechanism against that
The FileUpload.save method is highly recommended if you want to store the
file to disk. It prevents some common errors (e.g. it does not overwrite
existing files unless you tell it to) and stores the file in a memory
efficient way. You can access the file object directly via FileUpload.file.
Just be careful.
see more at https://bottlepy.org/docs/dev/tutorial.html#file-uploads
Upvotes: 2