def upload_image_to_s3(self, image_data): """ Uploads an image to S3 Image_data: InMemoryUploadedFileObject that responds to read() and seek() @return:Success and a URL corresponding to the uploaded object """ success = False s3_public_url = "" image_ok = False try: image_data.seek(0) image_ok = open_ended_image_submission.run_image_tests(image_data) except: log.exception("Could not create image and check it.") if image_ok: image_key = image_data.name + datetime.now().strftime("%Y%m%d%H%M%S") try: image_data.seek(0) success, s3_public_url = open_ended_image_submission.upload_to_s3(image_data, image_key, self.s3_interface) except: log.exception("Could not upload image to S3.") return success, image_ok, s3_public_url
def upload_image_to_s3(self, image_data): """ Uploads an image to S3 Image_data: InMemoryUploadedFileObject that responds to read() and seek() @return:Success and a URL corresponding to the uploaded object """ success = False s3_public_url = "" image_ok = False try: image_data.seek(0) image_ok = open_ended_image_submission.run_image_tests(image_data) except: log.exception("Could not create image and check it.") if image_ok: image_key = image_data.name + datetime.now().strftime( "%Y%m%d%H%M%S") try: image_data.seek(0) success, s3_public_url = open_ended_image_submission.upload_to_s3( image_data, image_key, self.s3_interface) except: log.exception("Could not upload image to S3.") return success, image_ok, s3_public_url