F
F
foonfyrick2021-02-21 18:27:56
Android
foonfyrick, 2021-02-21 18:27:56

Uploading a photo to a test site always returns a 201 code?

Tell me if I wrote the file upload correctly? Because no matter what path I specify, even if it's just a random set of characters, the answer is always 201.

val path =Uri.parse(data?.data?.path)
val file = File(path.toString())
val requestFile = file.absolutePath.toRequestBody("multipart/form-data".toMediaTypeOrNull())
val multipartBody = MultipartBody.Part.createFormData("file",file.name,requestFile)
repository.uploadPhoto(multipartBody)

I can specify any path in File("qwewqeewq") and it always returns 201 code, how can I understand if I'm sending the selected photo or it's not clear what?
I select a photo from the phone, and in onActivityResult I get it, then the code that is given above is executed.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question