-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task/rfr 1057 add attachments #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments inlinbe
8530f75
to
dd6c1b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-reviewed
override fun uploadAttachment( | ||
jwtToken: String, | ||
metaData: RequestMetaData, | ||
measurementId: Long, | ||
uploadable: Attachment, | ||
file: File, | ||
fileName: String, | ||
progressListener: UploadProgressListener | ||
progressListener: UploadProgressListener, | ||
): Result { | ||
val endpoint = attachmentsEndpoint(measurementId) | ||
return uploadFile(jwtToken, metaData, file, endpoint, progressListener) | ||
val measurementId = uploadable.identifier.measurementIdentifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to keep the PRs as small as possible, so I didn't try to refactor further here.
@@ -171,81 +171,98 @@ class DefaultUploader(private val apiEndpoint: String) : Uploader { | |||
* We wrap errors with [UploadFailed] so that the caller can handle this without crashing. | |||
* This way the SDK's `SyncPerformer` can determine if the sync should be repeated. | |||
*/ | |||
@Suppress("ComplexMethod") | |||
private fun handleUploadException(exception: Exception): Nothing { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to reduce the complexity of this method, so I extracted the network specific exception into an own method
/** | ||
* Assembles a `HttpContent` object which contains the metadata. | ||
* | ||
* @param metaData The metadata to convert. | ||
* @return The meta data as `HttpContent`. | ||
*/ | ||
fun preRequestBody(metaData: RequestMetaData): Map<String, String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This moved to Uploadable.toMap()
which seemed cleaner to me.
@@ -547,24 +520,20 @@ class DefaultUploader(private val apiEndpoint: String) : Uploader { | |||
* @return the [String] read from the InputStream. If an I/O error occurs while reading from the stream, the | |||
* already read string is returned which might my empty or cut short. | |||
*/ | |||
@Suppress("MemberVisibilityCanBePrivate", "NestedBlockDepth") // Part of the API | |||
@Suppress("MemberVisibilityCanBePrivate") // Part of the API | |||
@JvmStatic | |||
fun readInputStream(inputStream: InputStream): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just reduced the unnecessary double-nesting of the try catch blocks here.
file: File, | ||
fileName: String, | ||
progressListener: UploadProgressListener | ||
progressListener: UploadProgressListener, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started putting a comma after the last parameter in such multi-line formats, so when we add or remove a parameter only the added line is shown in git as changed, not the previously last line where we would just have to add a ,
at the end.
just fyi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a copy form collector
Uploaded
This PR:
serialization
dependency as the upload functionality should be independent from the serialization functionalityUploadable
class which replaces the oldRequestMetaData
construct... and adds support for the new attachment metadata fields: