From 2a6547c8ebc5cf081fd6d76e565b36095b07a380 Mon Sep 17 00:00:00 2001 From: Armin Date: Tue, 31 Oct 2023 12:16:44 +0100 Subject: [PATCH] Add filesEndpoint to Uploader interface --- .../kotlin/de/cyface/uploader/DefaultUploader.kt | 6 +++++- src/main/kotlin/de/cyface/uploader/Uploader.kt | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/de/cyface/uploader/DefaultUploader.kt b/src/main/kotlin/de/cyface/uploader/DefaultUploader.kt index 7f76d33..f8d6d0d 100644 --- a/src/main/kotlin/de/cyface/uploader/DefaultUploader.kt +++ b/src/main/kotlin/de/cyface/uploader/DefaultUploader.kt @@ -66,7 +66,7 @@ import javax.net.ssl.SSLException * To use this interface just call [DefaultUploader.upload] with an authentication token. * * @author Armin Schnabel - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 * @property apiEndpoint An API endpoint running a Cyface data collector service, like `https://some.url/api/v3` */ @@ -201,6 +201,10 @@ class DefaultUploader(private val apiEndpoint: String) : Uploader { return URL(returnUrlWithTrailingSlash(apiEndpoint) + "measurements") } + override fun filesEndpoint(measurementId: Long): URL { + return URL(returnUrlWithTrailingSlash(apiEndpoint) + "measurements/$measurementId/files") + } + @Throws( BadRequestException::class, UnauthorizedException::class, diff --git a/src/main/kotlin/de/cyface/uploader/Uploader.kt b/src/main/kotlin/de/cyface/uploader/Uploader.kt index 9a6cc62..027e131 100644 --- a/src/main/kotlin/de/cyface/uploader/Uploader.kt +++ b/src/main/kotlin/de/cyface/uploader/Uploader.kt @@ -28,7 +28,7 @@ import java.net.URL * Interface for uploading files to a Cyface Data Collector. * * @author Armin Schnabel - * @version 1.0.0 + * @version 1.1.0 * @since 1.0.0 */ interface Uploader { @@ -54,9 +54,17 @@ interface Uploader { ): Result /** - * @return the endpoint which will be used for the upload. + * @return the endpoint which will be used to upload the core measurement file. * @throws MalformedURLException if the endpoint address provided is malformed. */ @Throws(MalformedURLException::class) fun endpoint(): URL + + /** + * @param measurementId The id of the measurement the files are captured for. + * @return the endpoint which will be used to upload the attached files of a measurement. + * @throws MalformedURLException if the endpoint address provided is malformed. + */ + @Throws(MalformedURLException::class) + fun filesEndpoint(measurementId: Long): URL }