我想知道,应该为每个文件上传请求创建一个新的boto3客户端实例,还是使用共享实例?哪种方法正确?
@app.route('/', methods=['POST'])
def upload_file():
file = request.files['file']
file.save('/tmp/file.ext')
client = boto3.client('s3')
client.upload_file('/tmp/file.ext', # Path to local file
'my-space', # Name of Space
'file.ext') # Name for remote file
client = boto3.client('s3')
@app.route('/', methods=['POST'])
def upload_file():
file = request.files['file']
file.save('/tmp/file.ext')
client.upload_file('/tmp/file.ext', # Path to local file
'my-space', # Name of Space
'file.ext') # Name for remote file
答案 0 :(得分:0)
我会选择共享客户端。
client = boto3.client('s3')
@app.route('/', methods=['POST'])
def upload_file():
file = request.files['file']
file.save('/tmp/file.ext')
client.upload_file('/tmp/file.ext', 'my-space', 'file.ext')