Guest User

Untitled

a guest
Nov 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. def upload_(self, file, location):
  2. filename = secure_filename(file.filename)
  3.  
  4. #get extension file
  5. extension = os.path.splitext(filename)[1]
  6.  
  7. filename = str(uuid.uuid4()) + extension
  8.  
  9. path = os.path.join(current_app.config[location], filename)
  10. print file #<FileStorage: u'new.pdf' ('application/pdf')>
  11. print path #/home/app/static/docs/b567467a-0991-4ee6-9255-28f7257079f9.pdf
  12. print filename #b2c681f6-7ad1-4fd1-abbd-9cddd7972125.pdf
  13.  
  14. file.save(path ,filename)
  15.  
  16. return filename
  17.  
  18. file.save(path ,filename)
  19. File "/usr/local/lib/python2.7/dist-packages/werkzeug/datastructures.py", line 2706, in save
  20. copyfileobj(self.stream, dst, buffer_size)
  21. File "/usr/lib/python2.7/shutil.py", line 49, in copyfileobj
  22. buf = fsrc.read(length)
  23. TypeError: integer argument expected, got 'str'
Add Comment
Please, Sign In to add comment