Retrieve uploaded file in webapp2
Wed, 11 October 2017
uploaded_file.py
def get_uploaded_file(self, post_key_name): """ Get an uploaded file by post key name. :param str post_key_name: :rtype: cgi.FieldStorage :return: cgi.FieldStorage or None """ import cgi import logging field_storage = self.request.POST.get(post_key_name, None) if isinstance(field_storage, cgi.FieldStorage): file_data = field_storage.file.read() logging.error(field_storage) logging.error(field_storage.filename) logging.error(field_storage.type) return field_storage return None