def save_local_path(self, local_path: str, new_filename: str = None) -> Any: # TODO: we should perform a REGEX check to make sure that the filename is valid filename = os.path.basename(local_path) if not new_filename else new_filename datastream_name = DSUtil.get_datastream_name_from_filename(filename) dest_dir = DSUtil.get_datastream_directory(datastream_name=datastream_name, root=self._root) os.makedirs(dest_dir, exist_ok=True) # make sure the dest folder exists dest_path = os.path.join(dest_dir, filename) shutil.copy(local_path, dest_path) return dest_path
def save_local_path(self, local_path: str, new_filename: str = None): # TODO: we should perform a REGEX check to make sure that the filename is valid filename = os.path.basename( local_path) if not new_filename else new_filename datastream_name = DSUtil.get_datastream_name_from_filename(filename) subpath = DSUtil.get_datastream_directory( datastream_name=datastream_name) s3_path = self.root.join(subpath, filename) self.tmp.upload(local_path, s3_path) return s3_path