mirror of
https://github.com/appwrite/appwrite
synced 2026-05-21 16:08:22 +00:00
Updated docs
This commit is contained in:
parent
2bb543dd77
commit
41759d4374
61 changed files with 1223 additions and 22 deletions
|
|
@ -0,0 +1,22 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createOAuth2Session(
|
||||
provider: 'bitbucket',
|
||||
success: 'https://example.com',
|
||||
failure: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createRecovery(
|
||||
email: 'email@example.com',
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createSession(
|
||||
email: 'email@example.com',
|
||||
password: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.createVerification(
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
21
app/sdks/flutter-dart/docs/examples/account/create.md
Normal file
21
app/sdks/flutter-dart/docs/examples/account/create.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.create(
|
||||
email: 'email@example.com',
|
||||
password: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.deleteSession(
|
||||
sessionId: '[SESSION_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.deleteSessions();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/account/delete.md
Normal file
18
app/sdks/flutter-dart/docs/examples/account/delete.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.delete();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/account/get-logs.md
Normal file
18
app/sdks/flutter-dart/docs/examples/account/get-logs.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getLogs();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/account/get-prefs.md
Normal file
18
app/sdks/flutter-dart/docs/examples/account/get-prefs.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getPrefs();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/account/get-sessions.md
Normal file
18
app/sdks/flutter-dart/docs/examples/account/get-sessions.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.getSessions();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/account/get.md
Normal file
18
app/sdks/flutter-dart/docs/examples/account/get.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.get();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
21
app/sdks/flutter-dart/docs/examples/account/update-email.md
Normal file
21
app/sdks/flutter-dart/docs/examples/account/update-email.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateEmail(
|
||||
email: 'email@example.com',
|
||||
password: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/account/update-name.md
Normal file
20
app/sdks/flutter-dart/docs/examples/account/update-name.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateName(
|
||||
name: '[NAME]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updatePassword(
|
||||
password: 'password',
|
||||
oldPassword: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/account/update-prefs.md
Normal file
20
app/sdks/flutter-dart/docs/examples/account/update-prefs.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updatePrefs(
|
||||
prefs: {},
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateRecovery(
|
||||
userId: '[USER_ID]',
|
||||
secret: '[SECRET]',
|
||||
passwordA: 'password',
|
||||
passwordB: 'password',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Account account = Account(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = account.updateVerification(
|
||||
userId: '[USER_ID]',
|
||||
secret: '[SECRET]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/avatars/get-browser.md
Normal file
20
app/sdks/flutter-dart/docs/examples/avatars/get-browser.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = avatars.getBrowser(
|
||||
code: 'aa',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = avatars.getCreditCard(
|
||||
code: 'amex',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/avatars/get-favicon.md
Normal file
20
app/sdks/flutter-dart/docs/examples/avatars/get-favicon.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = avatars.getFavicon(
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/avatars/get-flag.md
Normal file
20
app/sdks/flutter-dart/docs/examples/avatars/get-flag.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = avatars.getFlag(
|
||||
code: 'af',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/avatars/get-image.md
Normal file
20
app/sdks/flutter-dart/docs/examples/avatars/get-image.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = avatars.getImage(
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/avatars/get-q-r.md
Normal file
20
app/sdks/flutter-dart/docs/examples/avatars/get-q-r.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Avatars avatars = Avatars(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = avatars.getQR(
|
||||
text: '[TEXT]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.createDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
data: {},
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.deleteDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
documentId: '[DOCUMENT_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
21
app/sdks/flutter-dart/docs/examples/database/get-document.md
Normal file
21
app/sdks/flutter-dart/docs/examples/database/get-document.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.getDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
documentId: '[DOCUMENT_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.listDocuments(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Database database = Database(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = database.updateDocument(
|
||||
collectionId: '[COLLECTION_ID]',
|
||||
documentId: '[DOCUMENT_ID]',
|
||||
data: {},
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/locale/get-continents.md
Normal file
18
app/sdks/flutter-dart/docs/examples/locale/get-continents.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getContinents();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountriesEU();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountriesPhones();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/locale/get-countries.md
Normal file
18
app/sdks/flutter-dart/docs/examples/locale/get-countries.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCountries();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/locale/get-currencies.md
Normal file
18
app/sdks/flutter-dart/docs/examples/locale/get-currencies.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.getCurrencies();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
18
app/sdks/flutter-dart/docs/examples/locale/get.md
Normal file
18
app/sdks/flutter-dart/docs/examples/locale/get.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Locale locale = Locale(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = locale.get();
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
23
app/sdks/flutter-dart/docs/examples/storage/create-file.md
Normal file
23
app/sdks/flutter-dart/docs/examples/storage/create-file.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
//const fs = require('fs');
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.createFile(
|
||||
file: null,
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/storage/delete-file.md
Normal file
20
app/sdks/flutter-dart/docs/examples/storage/delete-file.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.deleteFile(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.getFileDownload(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.getFilePreview(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/storage/get-file-view.md
Normal file
20
app/sdks/flutter-dart/docs/examples/storage/get-file-view.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.getFileView(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/storage/get-file.md
Normal file
20
app/sdks/flutter-dart/docs/examples/storage/get-file.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.getFile(
|
||||
fileId: '[FILE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
19
app/sdks/flutter-dart/docs/examples/storage/list-files.md
Normal file
19
app/sdks/flutter-dart/docs/examples/storage/list-files.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.listFiles(
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
22
app/sdks/flutter-dart/docs/examples/storage/update-file.md
Normal file
22
app/sdks/flutter-dart/docs/examples/storage/update-file.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Storage storage = Storage(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = storage.updateFile(
|
||||
fileId: '[FILE_ID]',
|
||||
read: [],
|
||||
write: [],
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.createMembership(
|
||||
teamId: '[TEAM_ID]',
|
||||
email: 'email@example.com',
|
||||
roles: [],
|
||||
url: 'https://example.com',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/teams/create.md
Normal file
20
app/sdks/flutter-dart/docs/examples/teams/create.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.create(
|
||||
name: '[NAME]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.deleteMembership(
|
||||
teamId: '[TEAM_ID]',
|
||||
inviteId: '[INVITE_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/teams/delete.md
Normal file
20
app/sdks/flutter-dart/docs/examples/teams/delete.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.delete(
|
||||
teamId: '[TEAM_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/teams/get-memberships.md
Normal file
20
app/sdks/flutter-dart/docs/examples/teams/get-memberships.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.getMemberships(
|
||||
teamId: '[TEAM_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
20
app/sdks/flutter-dart/docs/examples/teams/get.md
Normal file
20
app/sdks/flutter-dart/docs/examples/teams/get.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.get(
|
||||
teamId: '[TEAM_ID]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
19
app/sdks/flutter-dart/docs/examples/teams/list.md
Normal file
19
app/sdks/flutter-dart/docs/examples/teams/list.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.list(
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.updateMembershipStatus(
|
||||
teamId: '[TEAM_ID]',
|
||||
inviteId: '[INVITE_ID]',
|
||||
userId: '[USER_ID]',
|
||||
secret: '[SECRET]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
21
app/sdks/flutter-dart/docs/examples/teams/update.md
Normal file
21
app/sdks/flutter-dart/docs/examples/teams/update.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
// Init SDK
|
||||
Client client = Client();
|
||||
Teams teams = Teams(client);
|
||||
|
||||
client
|
||||
.setProject('5df5acd0d48c2') // Your project ID
|
||||
;
|
||||
|
||||
Future result = teams.update(
|
||||
teamId: '[TEAM_ID]',
|
||||
name: '[NAME]',
|
||||
);
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
});
|
||||
|
|
@ -1,48 +1,77 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:cookie_jar/cookie_jar.dart';
|
||||
import 'package:dio/adapter.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/adapter.dart';
|
||||
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
|
||||
import 'package:cookie_jar/cookie_jar.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
import 'enums.dart';
|
||||
|
||||
class Client {
|
||||
String endPoint;
|
||||
String type = 'unknown';
|
||||
Map<String, String> headers;
|
||||
Map<String, String> config;
|
||||
bool selfSigned;
|
||||
final Dio http;
|
||||
bool init = false;
|
||||
Dio http;
|
||||
PersistCookieJar cookieJar;
|
||||
|
||||
Client({this.endPoint = 'https://appwrite.io/v1', this.selfSigned = false, Dio http}) : this.http = http ?? Dio() {
|
||||
|
||||
type = (Platform.isIOS) ? 'ios' : type;
|
||||
type = (Platform.isMacOS) ? 'macos' : type;
|
||||
type = (Platform.isAndroid) ? 'android' : type;
|
||||
type = (Platform.isLinux) ? 'linux' : type;
|
||||
type = (Platform.isWindows) ? 'windows' : type;
|
||||
type = (Platform.isFuchsia) ? 'fuchsia' : type;
|
||||
|
||||
this.headers = {
|
||||
'content-type': 'application/json',
|
||||
'x-sdk-version': 'appwrite:dart:0.0.10',
|
||||
};
|
||||
|
||||
this.config = {};
|
||||
|
||||
assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'");
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
this.http.options.validateStatus = (status) => status != 404;
|
||||
this.http.interceptors.add(CookieManager(CookieJar()));
|
||||
}
|
||||
|
||||
Future<Directory> _getCookiePath() async {
|
||||
final directory = await getApplicationDocumentsDirectory();
|
||||
final path = directory.path;
|
||||
final Directory dir = new Directory('$path/cookies');
|
||||
await dir.create();
|
||||
return dir;
|
||||
}
|
||||
|
||||
/// Your project ID
|
||||
Client setProject(value) {
|
||||
config['project'] = value;
|
||||
addHeader('X-Appwrite-Project', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// Your secret API key
|
||||
Client setKey(value) {
|
||||
config['key'] = value;
|
||||
addHeader('X-Appwrite-Key', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setLocale(value) {
|
||||
config['locale'] = value;
|
||||
addHeader('X-Appwrite-Locale', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setMode(value) {
|
||||
config['mode'] = value;
|
||||
addHeader('X-Appwrite-Mode', value);
|
||||
return this;
|
||||
}
|
||||
|
||||
Client setSelfSigned({bool status = true}) {
|
||||
selfSigned = status;
|
||||
return this;
|
||||
|
|
@ -60,7 +89,7 @@ class Client {
|
|||
return this;
|
||||
}
|
||||
|
||||
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) {
|
||||
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) async {
|
||||
if(selfSigned) {
|
||||
// Allow self signed requests
|
||||
(http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) {
|
||||
|
|
@ -69,9 +98,25 @@ class Client {
|
|||
};
|
||||
}
|
||||
|
||||
if(!init) {
|
||||
final Directory cookieDir = await _getCookiePath();
|
||||
|
||||
cookieJar = new PersistCookieJar(dir:cookieDir.path);
|
||||
|
||||
this.http.options.baseUrl = this.endPoint;
|
||||
this.http.options.validateStatus = (status) => status < 400;
|
||||
this.http.interceptors.add(CookieManager(cookieJar));
|
||||
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
|
||||
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
|
||||
|
||||
init = true;
|
||||
}
|
||||
|
||||
// Origin is hardcoded for testing
|
||||
Options options = Options(
|
||||
headers: {...this.headers, ...headers, "Origin": "http://localhost"},
|
||||
headers: {...this.headers, ...headers},
|
||||
method: method.name(),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
|
|
@ -187,15 +190,32 @@ class Account extends Service {
|
|||
/// choice. Each OAuth2 provider should be enabled from the Appwrite console
|
||||
/// first. Use the success and failure arguments to provide a redirect URL's
|
||||
/// back to your app when login is completed.
|
||||
Future<Response> createOAuth2Session({@required String provider, @required String success, @required String failure}) {
|
||||
Future createOAuth2Session({@required String provider, @required String success, @required String failure}) {
|
||||
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'success': success,
|
||||
'failure': failure,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params);
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return FlutterWebAuth.authenticate(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: "appwrite-callback"
|
||||
).then((value) {
|
||||
Uri url = Uri.parse(value);
|
||||
List<Cookie> cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])];
|
||||
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
|
||||
}).catchError((error) {
|
||||
});
|
||||
}
|
||||
/// Use this endpoint to log out the currently logged in user from all his
|
||||
/// account sessions across all his different devices. When using the option id
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
|
|
@ -73,19 +76,36 @@ class Storage extends Service {
|
|||
/// Get file content by its unique ID. The endpoint response return with a
|
||||
/// 'Content-Disposition: attachment' header that tells the browser to start
|
||||
/// downloading the file to user downloads directory.
|
||||
Future<Response> getFileDownload({@required String fileId}) {
|
||||
Future getFileDownload({@required String fileId}) {
|
||||
final String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params);
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return FlutterWebAuth.authenticate(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: "appwrite-callback"
|
||||
).then((value) {
|
||||
Uri url = Uri.parse(value);
|
||||
List<Cookie> cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])];
|
||||
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
|
||||
}).catchError((error) {
|
||||
});
|
||||
}
|
||||
/// Get a file preview image. Currently, this method supports preview for image
|
||||
/// files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
||||
/// and spreadsheets, will return the file icon image. You can also pass query
|
||||
/// string arguments for cutting and resizing your preview image.
|
||||
Future<Response> getFilePreview({@required String fileId, int width = 0, int height = 0, int quality = 100, String background = '', String output = ''}) {
|
||||
Future getFilePreview({@required String fileId, int width = 0, int height = 0, int quality = 100, String background = '', String output = ''}) {
|
||||
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
|
|
@ -94,19 +114,53 @@ class Storage extends Service {
|
|||
'quality': quality,
|
||||
'background': background,
|
||||
'output': output,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params);
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return FlutterWebAuth.authenticate(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: "appwrite-callback"
|
||||
).then((value) {
|
||||
Uri url = Uri.parse(value);
|
||||
List<Cookie> cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])];
|
||||
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
|
||||
}).catchError((error) {
|
||||
});
|
||||
}
|
||||
/// Get file content by its unique ID. This endpoint is similar to the download
|
||||
/// method but returns with no 'Content-Disposition: attachment' header.
|
||||
Future<Response> getFileView({@required String fileId, String as = ''}) {
|
||||
Future getFileView({@required String fileId, String as = ''}) {
|
||||
final String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'as': as,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params);
|
||||
Uri endpoint = Uri.parse(client.endPoint);
|
||||
Uri url = new Uri(scheme: endpoint.scheme,
|
||||
host: endpoint.host,
|
||||
port: endpoint.port,
|
||||
path: endpoint.path + path,
|
||||
queryParameters:params,
|
||||
);
|
||||
|
||||
return FlutterWebAuth.authenticate(
|
||||
url: url.toString(),
|
||||
callbackUrlScheme: "appwrite-callback"
|
||||
).then((value) {
|
||||
Uri url = Uri.parse(value);
|
||||
List<Cookie> cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])];
|
||||
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
|
||||
}).catchError((error) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
||||
|
||||
import "../client.dart";
|
||||
import '../enums.dart';
|
||||
|
|
|
|||
|
|
@ -9,6 +9,29 @@ environment:
|
|||
sdk: '>=2.6.0 <3.0.0'
|
||||
dependencies:
|
||||
meta: ^1.1.8
|
||||
path_provider: ^1.6.5
|
||||
dio: ^3.0.0
|
||||
cookie_jar: ^1.0.0
|
||||
dio_cookie_manager: ^1.0.0
|
||||
flutter_web_auth: ^0.1.3
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^0.1.2
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
||||
# The following section is specific to Flutter.
|
||||
flutter:
|
||||
|
||||
# The following line ensures that the Material Icons font is
|
||||
# included with your application, so that you can use the icons in
|
||||
# the material Icons class.
|
||||
uses-material-design: true
|
||||
12
composer.lock
generated
12
composer.lock
generated
|
|
@ -239,12 +239,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/ca-bundle.git",
|
||||
"reference": "47fe531de31fca4a1b997f87308e7d7804348f7e"
|
||||
"reference": "95c63ab2117a72f48f5a55da9740a3273d45b7fd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/47fe531de31fca4a1b997f87308e7d7804348f7e",
|
||||
"reference": "47fe531de31fca4a1b997f87308e7d7804348f7e",
|
||||
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/95c63ab2117a72f48f5a55da9740a3273d45b7fd",
|
||||
"reference": "95c63ab2117a72f48f5a55da9740a3273d45b7fd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -287,7 +287,7 @@
|
|||
"ssl",
|
||||
"tls"
|
||||
],
|
||||
"time": "2020-01-13T10:02:55+00:00"
|
||||
"time": "2020-04-08T08:27:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dasprid/enum",
|
||||
|
|
@ -1622,7 +1622,7 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/appwrite/sdk-generator",
|
||||
"reference": "f8e7c334e672468ca9d2e616e10f2379ea890ae7"
|
||||
"reference": "31b451aee0a68f7247d206e949eed9a6f9e3bd72"
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
|
|
@ -1652,7 +1652,7 @@
|
|||
}
|
||||
],
|
||||
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
||||
"time": "2020-04-06T04:46:23+00:00"
|
||||
"time": "2020-04-08T17:00:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
|
|
|
|||
Loading…
Reference in a new issue