def get_files_from_storage(paths): """Return S3 file where the name does not include the path.""" for path in paths: path = path.replace(os.path.dirname(storage.location) + '/', '', 1) try: f = storage.open(path) f.name = os.path.basename(path) yield f except OSError: logger.exception("File not found: %s", path)
def get_files_from_storage(paths): """Return S3 file where the name does not include the path.""" for path in paths: path = pathlib.PurePosixPath(path) try: f = storage.open(str(path.relative_to(storage.location))) f.name = path.name yield f except (OSError, ValueError): logger.exception("File not found: %s", path)