コード例 #1
0
    def get_uploads():
        if request.method == "GET":
            tech_id = request.args['technician-id']
            s3 = create_client(app)

            files = s3_helpers.get_file_names(s3, bucket_name, tech_id)

            return {'files': files, 'technician_id': tech_id}
コード例 #2
0
def test_create_client():
    app = mock.Mock()
    app.config = {
        'S3_ENDPOINT_URL': 'somewhere',
        'S3_ACCESS_KEY_ID': '12345',
        'S3_SECRET_ACCESS_KEY': 'abcdef'
    }

    with mock.patch('boto3.client') as boto3_create_client:
        client = fileshare.create_client(app)
        ham.assert_that(client, ham.is_(boto3_create_client.return_value))
        boto3_create_client.assert_called_once_with(
            's3', aws_access_key_id='12345', aws_secret_access_key='abcdef')
コード例 #3
0
    def upload():
        if request.method == "POST":
            f = request.files['file']

            # give specific bad request if this isn't provided
            tech_id = request.form['technician-id']

            # give specific bad request if this isn't provided
            mach_id = request.form['machine-id']
            s3 = create_client(app)

            response = s3_helpers.upload_file(
                s3, bucket_name, f, tech_id, mach_id,
                datetime.now(
                    timezone('US/Central')).strftime('%Y-%m-%d_%H%M%S'))
            return str(response)
コード例 #4
0
 def home():
     s3 = create_client(app)
     return "apples"