ParseError while posting file with request
kiranlm opened this issue · 1 comments
kiranlm commented
I have tried to read file from request instead of physical path
gpxFile = request.files['gpx'].read()
gpx = gpxpy.parse(gpxFile)
This one give me some error like:
File "C:\Users\kiran\anaconda3\envs\runcoach\lib\xml\etree\ElementTree.py", line 1315, in XML
parser.feed(text)
File "<string>", line None
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 1
Below one is working fine when I tried reading from local file:
gpx_file = open('data/tcs.gpx', 'r')
gpx = gpxpy.parse(gpx_file)
How can I parse the file from request
tkrajina commented
gpxpy.parse(gpxFile)
accepts a file-like object or a string. In this case it probably isn't a valid file-like object or it's not a string. Log the type and contents of gpxFile
to see what's in there.
Anyway, I'm closing this since this isn't an "issue" (it's a question - stackoverflow is a better places for asking questions).