chore: update role helper class

This commit is contained in:
Christy Jacob
2022-09-22 08:47:34 +05:30
parent 5a2778047e
commit 4cbf5d21d8
3 changed files with 15 additions and 19 deletions
+2 -2
View File
@@ -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.
<script>
window.opener.postMessage({
flutter-web-auth2: window.location.href
flutter-web-auth-2: window.location.href
}, window.location.origin);
window.close();
</script>
+13 -13
View File
@@ -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!
-4
View File
@@ -33,8 +33,4 @@ class Role {
static String member(String id) {
return 'member:$id';
}
static String status(String status) {
return 'status:$status';
}
}