I am losing my mind on this issue:
I have a html file uploader, which returns a file that is read by a flask application. the file is then saved on a S3 bucket.
The html is something like this:
<form class="box" action="{{ to_url }}" method="POST" id="submit-form" enctype="multipart/form-data">
<div class="file is-boxed">
<label class="file-label">
<input class="file-input" type="file" name="file">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Carica file
</span>
</span>
</label>
</div>
</form>
And the flask code is something like this:
@app.route('/upload_participant_data', methods=['POST']) #definisce etodo ed endppoint
def upload_participant_data():
....
ff = request.files['file']
....
ff.seek(0)
print (ff.read(30))
Anyway, if I run the code and print the first 30 digits of the file in local, it returns me these values, which are the correct ones:
b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00C\x00\t\x06\x07\x08\x07'
If, on the other hand, I deploy my flask app on a lambda app, everything in the app works as expected, except the fact that now the first 30 digits of the file are read as:
b'\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xef\xbf'
And of course, the same happens for the rest of the file (it is all different). This, on cascade, cause that the wrong file is written on s3, and is then impossible to download and watch it back.
Do anyone knows what is happening? I am getting crazy