October 2019
Intermediate to advanced
426 pages
10h 8m
English
We can reuse the exact same implementation of StorageService from previous projects. We are only providing the methods we need for the current project, as follows:
import boto3class StorageService: def __init__(self, storage_location): self.client = boto3.client('s3') self.bucket_name = storage_location def upload_file(self, file_bytes, file_name): self.client.put_object(Bucket = self.bucket_name, Body = file_bytes, Key = file_name, ACL = 'public-read') return {'fileId': file_name, 'fileUrl': "http://" + self.bucket_name + ".s3.amazonaws.com/" + file_name}
For more details on the implementation and design choices, refer to Chapter 3, Detecting and Translating Text with Amazon Rekognition and ...
Read now
Unlock full access