def upload_file(self, source_file, account, container, object_name,
                    compress=True, content_type='application/x-gzip',
                    etag=None, headers=None):
        """
        Upload a file to cloud files.

        :param source_file: path to or file like object to upload
        :param account: account to upload to
        :param container: container to upload to
        :param object_name: name of object being uploaded
        :param compress: if True, compresses object as it is uploaded
        :param content_type: content-type of object
        :param etag: etag for object to check successful upload
        :returns: True if successful, False otherwise
        """
        target_name = '/v1/%s/%s/%s' % (account, container, object_name)

        # create the container
        if not self.create_container(account, container):
            return False

        send_headers = {'Transfer-Encoding': 'chunked'}
        if headers:
            send_headers.update(headers)

        # upload the file to the account
        req = swob.Request.blank(target_name,
                            environ={'REQUEST_METHOD': 'PUT'},
                            headers=send_headers)
        req.environ['content_type'] = content_type
        req.content_length = None   # to make sure we send chunked data
        if etag:
            req.headers['etag'] = etag
        resp = self._handle_request(req, source_file=source_file,
                                    compress=compress)
        if not (200 <= resp.status_int < 300):
            return False
        return True
dataset/ETHPy150Open notmyname/slogging/slogging/internal_proxy.py/InternalProxy.upload_file/original