Name of file to upload(android/kotlin)

Is there any possibility to upload file with changed name on android?

I have this in gradle file:

apollo {
    customTypeMapping = [
            "Upload" : "com.apollographql.apollo.api.FileUpload"

I create object of file to upload like this:

 FileUpload("image/jpeg", filepath)

I want to upload file with another name but don’t chane name in android filesystem. Can I do it without creating new file?

1 Like


This can be achieved by overriding the FileUpload class instead of using its constructor directly, like so:

  val file = File(filePath)
  return object : FileUpload("image/jpeg") {
    override fun contentLength() = file.length()
    override fun fileName() = "your file name here"
    override fun writeTo(sink: BufferedSink) {
1 Like