appwrite/docs/examples/1.0.x/client-flutter/examples/storage/create-file.md

25 lines
583 B
Markdown
Raw Normal View History

2022-09-01 04:49:47 +00:00
import 'dart:io';
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = storage.createFile(
bucketId: '[BUCKET_ID]',
fileId: '[FILE_ID]',
file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'),
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}