[U] Update usage
This commit is contained in:
@@ -18,7 +18,6 @@ class UploadWorker(
|
|||||||
val originalPhotoPath = inputData.getString("originalPhotoPath") ?: return Result.failure()
|
val originalPhotoPath = inputData.getString("originalPhotoPath") ?: return Result.failure()
|
||||||
val editedPhotoPath = inputData.getString("editedPhotoPath") ?: return Result.failure()
|
val editedPhotoPath = inputData.getString("editedPhotoPath") ?: return Result.failure()
|
||||||
val urlName = inputData.getString("urlName") ?: return Result.failure()
|
val urlName = inputData.getString("urlName") ?: return Result.failure()
|
||||||
val ownerKey = "1234" // This should probably be passed as an input argument as well
|
|
||||||
|
|
||||||
val originalPhoto = File(originalPhotoPath)
|
val originalPhoto = File(originalPhotoPath)
|
||||||
val editedPhoto = File(editedPhotoPath)
|
val editedPhoto = File(editedPhotoPath)
|
||||||
@@ -26,8 +25,7 @@ class UploadWorker(
|
|||||||
return try {
|
return try {
|
||||||
val backendClient = BackendClient()
|
val backendClient = BackendClient()
|
||||||
val response = backendClient.uploadImage(
|
val response = backendClient.uploadImage(
|
||||||
id = urlName,
|
ownerKey = urlName,
|
||||||
ownerKey = ownerKey,
|
|
||||||
originalPhoto = originalPhoto,
|
originalPhoto = originalPhoto,
|
||||||
editedPhoto = editedPhoto
|
editedPhoto = editedPhoto
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -34,12 +34,7 @@ class BackendClient {
|
|||||||
private const val SERVER_URL = "http://172.16.0.212:3000" // For Android emulator
|
private const val SERVER_URL = "http://172.16.0.212:3000" // For Android emulator
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun uploadImage(
|
suspend fun uploadImage(ownerKey: String, originalPhoto: File, editedPhoto: File): HttpResponse {
|
||||||
id: String,
|
|
||||||
ownerKey: String,
|
|
||||||
originalPhoto: File,
|
|
||||||
editedPhoto: File
|
|
||||||
): HttpResponse {
|
|
||||||
val origB = originalPhoto.readBytes()
|
val origB = originalPhoto.readBytes()
|
||||||
val editB = editedPhoto.readBytes()
|
val editB = editedPhoto.readBytes()
|
||||||
println(origB.size)
|
println(origB.size)
|
||||||
@@ -49,14 +44,11 @@ class BackendClient {
|
|||||||
append("x-instant-key", API_KEY)
|
append("x-instant-key", API_KEY)
|
||||||
}
|
}
|
||||||
setBody(
|
setBody(
|
||||||
MultiPartFormDataContent(
|
MultiPartFormDataContent(formData {
|
||||||
formData {
|
append("owner_key", ownerKey)
|
||||||
append("id", id)
|
append("\"photo\"", originalPhoto.name, ContentType.Image.JPEG, origB.size.toLong()) { write(origB) }
|
||||||
append("owner_key", ownerKey)
|
append("\"edited_photo\"", editedPhoto.name, ContentType.Image.JPEG, editB.size.toLong()) { write(editB) }
|
||||||
append("\"photo\"", originalPhoto.name, ContentType.Image.JPEG, origB.size.toLong()) { write(origB) }
|
})
|
||||||
append("\"edited_photo\"", editedPhoto.name, ContentType.Image.JPEG, editB.size.toLong()) { write(editB) }
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
timeout { HttpTimeoutConfig(1 * 60 * 1000L) }
|
timeout { HttpTimeoutConfig(1 * 60 * 1000L) }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user