0

I have a web app build with pyramid. One of the endpoints /foo is connected to the method foo(request):

def foo(request):
    file = request.POST['my_file'].file
    ...do stuff with file...

I then send a file to the endpoint using postman. The problem is, the file is opened as a BufferedRandom in binary mode, but I need to manipulate the file in text mode. Is it possible to do this?

Mike S
  • 1,451
  • 1
  • 16
  • 34

1 Answers1

0

Found my answer here: Not able to parse a .csv file uploaded using Flask

In my case I added

stream = io.StringIO(file.read().decode("utf8"), newline=None)

and was able to manipulate stream

Mike S
  • 1,451
  • 1
  • 16
  • 34