-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreateBucket.cpp
43 lines (37 loc) · 1.21 KB
/
createBucket.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "Appwrite.hpp"
#include <iostream>
int main() {
std::string projectId = "66fbb5a100070a3a1d19";
std::string apiKey = "";
std::string bucketId = "bucket12322";
std::string name = "testBucketnew";
Appwrite appwrite(projectId);
Storage& storage = appwrite.getStorage();
storage.setup(apiKey, projectId);
std::vector<std::string> permissions = {"read(\"any\")", "write(\"any\")"};
bool fileSecurity = true;
bool enabled = true;
int maximumFileSize = 30000000;
std::vector<std::string> allowedFileExtensions = {"jpg", "png", "pdf"};
std::string compression = "gzip";
bool antivirus = true;
bool encryption = true;
try {
std::string response = storage.createBucket(
bucketId,
name,
permissions,
fileSecurity,
enabled,
maximumFileSize,
allowedFileExtensions,
compression,
encryption,
antivirus
);
std::cout << "Bucket created successfully! \nResponse: " << response << std::endl;
} catch (const AppwriteException& ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
}
return 0;
}