From 4cbf5d21d8de6a7274fe48def1a5b6dfb5ceec58 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 22 Sep 2022 08:47:34 +0530 Subject: [PATCH] chore: update role helper class --- README.md | 4 ++-- example/README.md | 26 +++++++++++++------------- lib/role.dart | 4 ---- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index ca793a0..3b24ad2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.0.0. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).** +**This SDK is compatible with Appwrite server version 1.0.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -91,7 +91,7 @@ For web in order to capture the OAuth2 callback URL and send it to the applicati close the window. diff --git a/example/README.md b/example/README.md index c205444..23b6319 100644 --- a/example/README.md +++ b/example/README.md @@ -3,14 +3,13 @@ Init your Appwrite client: ```dart - Client client = Client(); - - client - .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint - .setProject('5e8cf4f46b5e8') // Your project ID - .setSelfSigned() // Remove in production - ; +Client client = Client(); +client + .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setProject('5e8cf4f46b5e8') // Your project ID + .setSelfSigned() // Remove in production +; ``` Create a new user and session: @@ -18,9 +17,9 @@ Create a new user and session: ```dart Account account = Account(client); -Response user = await account.create(userId: '[USER_ID]', email: 'me@appwrite.io', password: 'password', name: 'My Name'); +final user = await account.create(userId: '[USER_ID]', email: 'me@appwrite.io', password: 'password', name: 'My Name'); -Response session = await account.createSession(email: 'me@appwrite.io', password: 'password'); +final session = await account.createEmailSession(email: 'me@appwrite.io', password: 'password'); ``` @@ -29,7 +28,7 @@ Fetch user profile: ```dart Account account = Account(client); -Response profile = await account.get(); +final profile = await account.get(); ``` Upload File: @@ -40,7 +39,7 @@ Storage storage = Storage(client); late InputFile file; if(kIsWeb) { - file = InputFile(file: await MultipartFile.fromFile('file', './path-to-file/image.jpg', filename: 'image.jpg')); + file = InputFile(bytes: pickedFile.bytes, filename: 'image.jpg'); } else { file = InputFile(path: './path-to-file/image.jpg', filename: 'image.jpg'); } @@ -49,8 +48,9 @@ storage.createFile( bucketId: '[BUCKET_ID]', fileId: '[FILE_ID]', // use 'unique()' to automatically generate a unique ID file: file, - read: ['role:all'], - write: [] + permissions: [ + Permission.read(Role.any()), + ], ) .then((response) { print(response); // File uploaded! diff --git a/lib/role.dart b/lib/role.dart index de0a8ed..9d72db7 100644 --- a/lib/role.dart +++ b/lib/role.dart @@ -33,8 +33,4 @@ class Role { static String member(String id) { return 'member:$id'; } - - static String status(String status) { - return 'status:$status'; - } } \ No newline at end of file