I am trying to upload a CSV file of 60 mb to my application. But when i save the file to server , it only contains partial(25 mb) of total records from the original. This issue is occurring only randomly.
@fileupload.route('/loadfile',methods = ['POST'])
def store_to_db():
for _file in request.files.getlist('filelist'):
name, ext = FileUtil.get_filename_without_ext(_file.filename)#fetching file name and extension
fd, path = tempfile.mkstemp(suffix=ext, prefix=name)#saving file as temp
os.write(fd, _file.read())
try:
file_upload_service.savefiletodb(path)
except Exception as e:
logger.info(str(e))
os.close(fd)
Uploader side code:
data= {}
url_path = 'localhost:5000/loadfile'
data['filelist']=open('employe.txt', 'rb')
resp = requests.post(url=url_path, files=data)
Any idea why its behaving like this ?
Note:
When i upload through postman, i am not facing any issue.
If I upload through code , sometimes I get partial file.
file object in log , when upload via postman
'employee.TXT' ('text/plain')>
file object in log , when upload via code
'employee.TXT' ('None')>