Skip to content
post

Create File

Endpoint

posthttps://<REGION>.cloud.appwrite.io/v1/storage/buckets/{bucketId}/files

Description

Required scopes

files.write

Authentication

Initialize the Appwrite client with setProject() and ensure the user is signed in. The SDK sends the session header automatically after login.

Path

string
Required

Body

string
Required
string
Required
array
array
Status
Content type
201
application/json

File

Name
Type
Description
string
string
integer
integer
arrayof string
arrayof string
string
string
string
integer
integer
integer
Kotlin
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.models.InputFile
import io.appwrite.services.Storage
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val client = Client(applicationContext)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val storage = Storage(client)
GlobalScope.launch {
val response = storage.createFile(
bucketId = "[BUCKET_ID]",
fileId = "[FILE_ID]",
file = InputFile.fromPath("file.png"),
)
val json = response.body?.string()
}
}
}