Skip to content

Instantly share code, notes, and snippets.

@gewenyu99
Created May 3, 2022 00:13
Show Gist options
  • Save gewenyu99/fc660609e1bd20978077d0ff753b1741 to your computer and use it in GitHub Desktop.
Save gewenyu99/fc660609e1bd20978077d0ff753b1741 to your computer and use it in GitHub Desktop.
Kotlin File Create Test
import io.appwrite.Client
import io.appwrite.services.Storage
import java.io.File
suspend fun main() {
val client = Client()
.setEndpoint("https://demo.appwrite.io/v1") // Your API Endpoint
.setProject("61e71ec784ab035f7259") // Your project ID
.setKey("dfca63d558ac96201528c0027252de131939d7d46b2c097fae0f91e17c24660056feaac69645727ca7f8b494629d5c8c99c9d35446e12b4a990874293e1ebdc5aba9b88933037ddf90c4048f6d9f17e4fa58c19a756bb23dd273a0c25baaea874a24cba8d9cbd25cb34704bb9d9e99f22f403c37b2f7839a3e2bfd4d3fc8720c") // Your secret API key
val storage = Storage(client)
val response = storage.createFile(
bucketId = "default",
fileId = "unique()",
file = File("test.file"),
)
print(response.id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment