hbp_service_client/storage_service/client.py
def upload_file(self, local_file, dest_path, mimetype):
        '''Upload local file content to a storage service destination folder.

            Args:
                local_file(str)
                dest_path(str):
                    absolute Storage service path '/project' prefix is essential
                    suffix should be the name the file will have on in the destination folder
                    i.e.: /project/folder/.../file_name
                mimetype(str): set the contentType attribute

            Returns:
                The uuid of created file entity as string

            Raises:
                StorageArgumentException: Invalid arguments
                StorageForbiddenException: Server response code 403
                StorageNotFoundException: Server response code 404
                StorageException: other 400-600 error codes
        '''

        self.__validate_storage_path(dest_path)
        # get the paths of the target dir and the target file name
        if dest_path.endswith('/'):
            raise StorageArgumentException('Must specify target file name in dest_path argument')
        if local_file.endswith(os.path.sep):
            raise StorageArgumentException('Must specify source file name in local_file'
                                           ' argument, directory upload not supported')

        # create the file container
        new_file = self.api_client.create_file(
            name=dest_path.split('/').pop(),
            content_type=mimetype,
            parent=self.get_parent(dest_path)['uuid']
        )

        etag = self.api_client.upload_file_content(new_file['uuid'], source=local_file)
        new_file['etag'] = etag

        return new_file
def upload_file(self, local_file, dest_path, mimetype):
        '''Upload local file content to a storage service destination folder.

            Args:
                local_file(str)
                dest_path(str):
                    absolute Storage service path '/project' prefix is essential
                    suffix should be the name the file will have on in the destination folder
                    i.e.: /project/folder/.../file_name
                mimetype(str): set the contentType attribute

            Returns:
                The uuid of created file entity as string

            Raises:
                StorageArgumentException: Invalid arguments
                StorageForbiddenException: Server response code 403
                StorageNotFoundException: Server response code 404
                StorageException: other 400-600 error codes
        '''

        self.__validate_storage_path(dest_path)
        # get the paths of the target dir and the target file name
        if dest_path.endswith('/'):
            raise StorageArgumentException('Must specify target file name in dest_path argument')
        if local_file.endswith(os.path.sep):
            raise StorageArgumentException('Must specify source file name in local_file'
                                           ' argument, directory upload not supported')

        # create the file container
        new_file = self.api_client.create_file(
            name=dest_path.split('/').pop(),
            content_type=mimetype,
            parent=self.get_parent(dest_path)['uuid']
        )

        etag = self.api_client.upload_file_content(new_file['uuid'], source=local_file)
        new_file['etag'] = etag

        return new_file
Upload local file content to a storage service destination folder.

            Args:
                local_file(str)
                dest_path(str):
                    absolute Storage service path '/project' prefix is essential
                    suffix should be the name the file will have on in the destination folder
                    i.e.: /project/folder/.../file_name
                mimetype(str): set the contentType attribute

            Returns:
                The uuid of created file entity as string

            Raises:
                StorageArgumentException: Invalid arguments
                StorageForbiddenException: Server response code 403
                StorageNotFoundException: Server response code 404
                StorageException: other 400-600 error codes