Appwrite C++ SDK
Auto-generated API documentation for the Appwrite C++ SDK
Loading...
Searching...
No Matches
Storage Class Reference

Provides methods to interact with Appwrite's Storage service. More...

#include <Storage.hpp>

Collaboration diagram for Storage:

Public Member Functions

std::string createBucket (const std::string &bucketId, const std::string &name, const std::vector< std::string > &permissions={}, bool fileSecurity=false, bool enabled=true, int maximumFileSize=0, const std::vector< std::string > &allowedFileExtensions={}, const std::string &compression="none", bool encryption=false, bool antivirus=false)
 Creates a new storage bucket.
 
std::string createFile (const std::string &bucketId, const std::string &fileName, const std::string &fileContent, const std::vector< std::string > &permissions)
 Uploads a file to the specified bucket.
 
std::string deleteBucket (std::string &bucketId)
 Deletes a storage bucket.
 
std::string deleteFile (const std::string &bucketId, const std::string &fileId)
 Deletes a file from the bucket.
 
std::string getBucket (std::string &bucketId)
 Retrieves metadata of a specific bucket.
 
std::string getFile (const std::string &bucketId, const std::string &fileId)
 Retrieves metadata of a specific file.
 
std::string getFileDownload (const std::string &bucketId, const std::string &fileId)
 Returns a downloadable URL for a file.
 
std::string getFileView (const std::string &bucketId, const std::string &fileId)
 Returns a file preview URL.
 
std::string listBuckets ()
 Lists all buckets in the project.
 
 Storage (const std::string &projectId, const std::string &apiKey)
 Constructs the Storage client with given project ID and API key.
 
std::string updateBucket (const std::string &bucketId, const std::string &name, const std::vector< std::string > &permissions={}, bool fileSecurity=false, bool enabled=true, int maximumFileSize=0, const std::vector< std::string > &allowedFileExtensions={}, const std::string &compression="none", bool encryption=false, bool antivirus=false)
 Updates an existing storage bucket.
 
std::string updateFile (const std::string &bucketId, const std::string &fileId, const std::string &name="", const std::vector< std::string > &permissions={})
 Updates file metadata and permissions.
 

Detailed Description

Provides methods to interact with Appwrite's Storage service.

Enables management of buckets and files including creation, retrieval, update, and deletion.

Definition at line 19 of file Storage.hpp.

Constructor & Destructor Documentation

◆ Storage()

Storage::Storage ( const std::string &  projectId,
const std::string &  apiKey 
)

Constructs the Storage client with given project ID and API key.

Parameters
projectIdThe unique identifier of the Appwrite project.
apiKeyThe secret API key for authentication.

Member Function Documentation

◆ createBucket()

std::string Storage::createBucket ( const std::string &  bucketId,
const std::string &  name,
const std::vector< std::string > &  permissions = {},
bool  fileSecurity = false,
bool  enabled = true,
int  maximumFileSize = 0,
const std::vector< std::string > &  allowedFileExtensions = {},
const std::string &  compression = "none",
bool  encryption = false,
bool  antivirus = false 
)

Creates a new storage bucket.

Parameters
bucketIdUnique ID for the bucket.
nameName of the bucket.
permissionsOptional permissions list.
fileSecurityFlag for enabling file-level security.
enabledEnables or disables the bucket.
maximumFileSizeOptional max file size limit.
allowedFileExtensionsOptional list of allowed file extensions.
compressionCompression type ("none", "gzip", etc.).
encryptionEnable server-side encryption.
antivirusEnable antivirus scanning.
Returns
JSON string with creation response.

◆ createFile()

std::string Storage::createFile ( const std::string &  bucketId,
const std::string &  fileName,
const std::string &  fileContent,
const std::vector< std::string > &  permissions 
)

Uploads a file to the specified bucket.

Parameters
bucketIdTarget bucket ID.
fileNameName to give the file.
fileContentFile content (base64 or raw).
permissionsOptional permissions list.
Returns
JSON response string.

◆ deleteBucket()

std::string Storage::deleteBucket ( std::string &  bucketId)

Deletes a storage bucket.

Parameters
bucketIdID of the bucket to delete.
Returns
JSON response string.

◆ deleteFile()

std::string Storage::deleteFile ( const std::string &  bucketId,
const std::string &  fileId 
)

Deletes a file from the bucket.

Parameters
bucketIdBucket ID.
fileIdFile ID.
Returns
JSON response string.

◆ getBucket()

std::string Storage::getBucket ( std::string &  bucketId)

Retrieves metadata of a specific bucket.

Parameters
bucketIdID of the bucket to retrieve.
Returns
JSON string containing bucket details.

◆ getFile()

std::string Storage::getFile ( const std::string &  bucketId,
const std::string &  fileId 
)

Retrieves metadata of a specific file.

Parameters
bucketIdBucket ID where file is stored.
fileIdUnique file identifier.
Returns
JSON string containing file metadata.

◆ getFileDownload()

std::string Storage::getFileDownload ( const std::string &  bucketId,
const std::string &  fileId 
)

Returns a downloadable URL for a file.

Parameters
bucketIdBucket ID.
fileIdFile ID.
Returns
URL string for downloading the file.

◆ getFileView()

std::string Storage::getFileView ( const std::string &  bucketId,
const std::string &  fileId 
)

Returns a file preview URL.

Parameters
bucketIdBucket ID.
fileIdFile ID.
Returns
URL string for viewing the file.

◆ listBuckets()

std::string Storage::listBuckets ( )

Lists all buckets in the project.

Returns
JSON string containing the list of buckets.

◆ updateBucket()

std::string Storage::updateBucket ( const std::string &  bucketId,
const std::string &  name,
const std::vector< std::string > &  permissions = {},
bool  fileSecurity = false,
bool  enabled = true,
int  maximumFileSize = 0,
const std::vector< std::string > &  allowedFileExtensions = {},
const std::string &  compression = "none",
bool  encryption = false,
bool  antivirus = false 
)

Updates an existing storage bucket.

Parameters
bucketIdUnique ID of the bucket.
nameNew name for the bucket.
permissionsUpdated permissions list.
fileSecurityUpdated file-level security flag.
enabledWhether the bucket is enabled.
maximumFileSizeUpdated max file size limit.
allowedFileExtensionsUpdated list of allowed extensions.
compressionUpdated compression type.
encryptionToggle encryption.
antivirusToggle antivirus.
Returns
JSON string with update response.

◆ updateFile()

std::string Storage::updateFile ( const std::string &  bucketId,
const std::string &  fileId,
const std::string &  name = "",
const std::vector< std::string > &  permissions = {} 
)

Updates file metadata and permissions.

Parameters
bucketIdBucket ID.
fileIdFile ID.
nameNew name for the file (optional).
permissionsNew permissions list.
Returns
JSON response string.

The documentation for this class was generated from the following file: