Skip to content

Instantly share code, notes, and snippets.

@rybalkinsd
Created July 9, 2019 21:49
Show Gist options
  • Save rybalkinsd/a6b1cb20fab17d2c7a092c7b4c94de72 to your computer and use it in GitHub Desktop.
Save rybalkinsd/a6b1cb20fab17d2c7a092c7b4c94de72 to your computer and use it in GitHub Desktop.
Example of file upload to Google Drive with meta
val token = ...
val yourFile = ...
val response = httpPost {
url("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart")
header {
"Authorization" to "Bearer $token"
}
multipartBody {
+FormDataPart("meta", null, RequestBody.create(
MediaType.get("application/json"),
json {
"name" to "supercat"
}
))
+form("image", yourFile)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment