def run(self, bucket, file_name, remote_file=None):
        if not remote_file:
            remote_file = os.path.basename(file_name)

        if not os.path.isfile(file_name):
            raise ValueError('Local file "%s" doesn\'t exist' % (file_name))

        url = S3_BUCKET_URL % {'bucket': bucket}
        url = url + remote_file

        # Note: Requests library performs streaming and chunked upload
        files = {'file': open(file_name, 'rb')}
        response = requests.put(url=url, files=files)

        if response.status_code in [httplib.OK, httplib.CREATED]:
            status = 'ok'
            error = None
        else:
            status = 'failure'
            error = response.text

        result = {
            'status_code': response.status_code,
            'status': status,
            'uploaded_file': remote_file,
        }

        if error:
            result['error'] = error

        return result
dataset/ETHPy150Open StackStorm/st2contrib/packs/st2/actions/upload_to_s3.py/UploadToS3.run/original