mirror of
https://github.com/appwrite/sdk-for-flutter.git
synced 2026-04-07 19:27:41 +00:00
chore: update role helper class
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
[](https://twitter.com/appwrite)
|
||||
[](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
@@ -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!
|
||||
|
||||
@@ -33,8 +33,4 @@ class Role {
|
||||
static String member(String id) {
|
||||
return 'member:$id';
|
||||
}
|
||||
|
||||
static String status(String status) {
|
||||
return 'status:$status';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user