diff --git a/swh/deposit/models.py b/swh/deposit/models.py --- a/swh/deposit/models.py +++ b/swh/deposit/models.py @@ -161,19 +161,19 @@ return "%s/%s" % (self.client.provider_url.rstrip("/"), self.external_id) -def client_directory_path(instance, filename): - """Callable to upload archive in MEDIA_ROOT/user_/ +def client_directory_path(instance: "DepositRequest", filename: str) -> str: + """Callable to determine the upload archive path. This defaults to + MEDIA_ROOT/client_/%Y%m%d-%H%M%S/. Args: - instance (DepositRequest): DepositRequest concerned by the upload - filename (str): Filename of the uploaded file + instance: DepositRequest concerned by the upload + filename: Filename of the uploaded file Returns: - A path to be prefixed by the MEDIA_ROOT to access physically - to the file uploaded. + The upload archive path. """ - return "client_{0}/{1}".format(instance.deposit.client.id, filename) + return "client_{0}/%Y%m%d-%H%M%S/{1}".format(instance.deposit.client.id, filename) REQUEST_TYPES = [(ARCHIVE_TYPE, ARCHIVE_TYPE), (METADATA_TYPE, METADATA_TYPE)]