From 4a6e1258ce881aa209597d3aa04284e90ca700bc Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Fri, 25 Apr 2025 21:54:02 +0100 Subject: [PATCH 01/10] Add React Native examples to storage dos --- .../products/storage/images/+page.markdoc | 38 ++++ .../storage/quick-start/+page.markdoc | 41 +++++ .../storage/upload-download/+page.markdoc | 163 +++++++++++++++++- 3 files changed, 234 insertions(+), 8 deletions(-) diff --git a/src/routes/docs/products/storage/images/+page.markdoc b/src/routes/docs/products/storage/images/+page.markdoc index 72b4aeab94..4436e85b11 100644 --- a/src/routes/docs/products/storage/images/+page.markdoc +++ b/src/routes/docs/products/storage/images/+page.markdoc @@ -183,5 +183,43 @@ class MainActivity : AppCompatActivity() { } } ``` +```client-react-native +import { Client, Storage, ImageGravity } from 'react-native-appwrite'; +import { Image } from 'react-native'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + +const storage = new Storage(client); + +// Get image with transformations +const result = storage.getFilePreview( + 'photos', // bucket ID + 'sunset.png', // file ID + 1800, // width, will be resized using this value + 0, // height, ignored when 0 + ImageGravity.Center,// crop center + 90, // slight compression + 5, // border width + 'CDCA30', // border color + 15, // border radius + 1, // full opacity + 0, // no rotation + 'FFFFFF', // background color + 'jpg' // output jpg format +); + +console.log(result); // Resource URL + +// Usage in a component +const ImagePreview = () => ( + +); +``` {% /multicode %} diff --git a/src/routes/docs/products/storage/quick-start/+page.markdoc b/src/routes/docs/products/storage/quick-start/+page.markdoc index ed69ca390b..4dc5aa6017 100644 --- a/src/routes/docs/products/storage/quick-start/+page.markdoc +++ b/src/routes/docs/products/storage/quick-start/+page.markdoc @@ -117,6 +117,33 @@ To upload a file, add this to your app. For web apps, you can use the File objec } ``` + ```client-react-native + import { Client, Storage, ID } from 'react-native-appwrite'; + + const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + + const storage = new Storage(client); + + const promise = storage.createFile( + '[BUCKET_ID]', + ID.unique(), + { + name: 'image.jpg', + type: 'image/jpeg', + size: 1234567, + uri: 'file:///path/to/file.jpg', + } + ); + + promise.then(function (response) { + console.log(response); // Success + }, function (error) { + console.log(error); // Failure + }); + ``` + ```http POST /v1/storage/buckets/{bucketId}/files HTTP/1.1 Content-Type: multipart/form-data; boundary="cec8e8123c05ba25" @@ -244,4 +271,18 @@ class MainActivity : AppCompatActivity() { } } ``` + +```client-react-native +import { Client, Storage } from 'react-native-appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + +const storage = new Storage(client); + +const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); + +console.log(result); // Resource URL +``` {% /multicode %} diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index d4be63b95e..80ab96bdfb 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -94,6 +94,33 @@ You can also upload files programmatically using our SDKs: } ``` + ```client-react-native + import { Client, Storage, ID } from 'react-native-appwrite'; + + const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + + const storage = new Storage(client); + + const promise = storage.createFile( + '[BUCKET_ID]', + ID.unique(), + { + name: 'image.jpg', + type: 'image/jpeg', + size: 1234567, + uri: 'file:///path/to/file.jpg', + } + ); + + promise.then(function (response) { + console.log(response); // Success + }, function (error) { + console.log(error); // Failure + }); + ``` + ```client-apple import Appwrite @@ -196,6 +223,61 @@ The Appwrite Apple SDK expects an `InputFile` class for file inputs. | `InputFile.fromData(_ data: Data, filename: String, mimeType: String)` | Used to upload files from a [Data](https://developer.apple.com/documentation/foundation/data) object. Specify the file [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) using the `mimeType` param. | | `InputFile.fromBuffer(_ buffer: ByteBuffer, filename: String, mimeType: String)` | Used to upload files from a [NIO Buffer](https://swiftinit.org/reference/swift-nio/niocore/bytebuffer) object. Specify the file [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) using the `mimeType` param. | {% /tabsitem %} + +{% tabsitem #react-native title="React Native" %} +The Appwrite React Native SDK expects a file object with the following properties for file inputs: + +| Property | Description | +| -------- | ----------- | +| `name` | The name of the file. | +| `type` | The MIME type of the file. | +| `size` | The size of the file in bytes. | +| `uri` | The URI of the file on the device. | + +This object structure aligns with what is typically returned from image picker libraries such as `react-native-image-picker`: + +```js +// Example with react-native-image-picker +import { launchImageLibrary } from 'react-native-image-picker'; + +const pickImage = async () => { + const result = await launchImageLibrary({ + mediaType: 'photo', + }); + + if (result.assets && result.assets[0]) { + const fileInfo = result.assets[0]; + + return { + name: fileInfo.fileName, + type: fileInfo.type, + size: fileInfo.fileSize, + uri: fileInfo.uri, + }; + } +}; +``` + +You can also use the file picker or document picker from Expo: + +```js +// Example with expo-document-picker +import * as DocumentPicker from 'expo-document-picker'; + +const pickDocument = async () => { + const result = await DocumentPicker.getDocumentAsync(); + + if (result.assets && result.assets[0]) { + return { + name: result.assets[0].name, + type: result.assets[0].mimeType, + size: result.assets[0].size, + uri: result.assets[0].uri, + }; + } +}; +``` +{% /tabsitem %} {% /tabs %} # Server SDKs {% #server-sdks %} @@ -360,15 +442,17 @@ import Appwrite func main() async throws { let client = Client() - .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint - .setProject("") // Your project ID - let storage = Storage(client) - let byteBuffer = try await storage.getFile( - bucketId: "[BUCKET_ID]", - fileId: "[FILE_ID]" - ) + .setEndpoint("https://.cloud.appwrite.io/v1") + .setProject("") - print(String(describing: byteBuffer) + let storage = Storage(client) + + let byteBuffer = try await storage.getFile( + bucketId: "[BUCKET_ID]", + fileId: "[FILE_ID]" + ) + + print(String(describing: byteBuffer) } ``` ```client-android-kotlin @@ -398,6 +482,23 @@ class MainActivity : AppCompatActivity() { } } ``` +```client-react-native +import { Client, Storage } from 'react-native-appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + +const storage = new Storage(client); + +const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]'); + +promise.then(function (response) { + console.log(response); // Success +}, function (error) { + console.log(error); // Failure +}); +``` {% /multicode %} # Download file {% #download-file %} @@ -501,6 +602,19 @@ class MainActivity : AppCompatActivity() { } } ``` +```client-react-native +import { Client, Storage } from 'react-native-appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + +const storage = new Storage(client); + +const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); + +console.log(result); // Resource URL +``` {% /multicode %} # Get File Preview {% #get-file-preview %} @@ -604,6 +718,26 @@ class MainActivity : AppCompatActivity() { } } ``` +```client-react-native +import { Client, Storage, ImageGravity } from 'react-native-appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + +const storage = new Storage(client); + +const result = storage.getFilePreview( + '[BUCKET_ID]', + '[FILE_ID]', + 200, // width + 200, // height + ImageGravity.Center, // gravity + 100 // quality +); + +console.log(result); // Resource URL +``` {% /multicode %} # View File {% #view-file%} @@ -708,4 +842,17 @@ class MainActivity : AppCompatActivity() { } } ``` +```client-react-native +import { Client, Storage } from 'react-native-appwrite'; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') + .setProject(''); + +const storage = new Storage(client); + +const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]'); + +console.log(result); // Resource URL +``` {% /multicode %} From 8b2779c285b0266667996377bc293dfd79ff8877 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:19:06 +0100 Subject: [PATCH 02/10] Update src/routes/docs/products/storage/upload-download/+page.markdoc Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/routes/docs/products/storage/upload-download/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index 80ab96bdfb..eefec1c68b 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -104,7 +104,7 @@ You can also upload files programmatically using our SDKs: const storage = new Storage(client); const promise = storage.createFile( - '[BUCKET_ID]', + '', ID.unique(), { name: 'image.jpg', From 757c6bca22522c218e9f4e1261e30423dc70c513 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:19:12 +0100 Subject: [PATCH 03/10] Update src/routes/docs/products/storage/quick-start/+page.markdoc Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/routes/docs/products/storage/quick-start/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/products/storage/quick-start/+page.markdoc b/src/routes/docs/products/storage/quick-start/+page.markdoc index 4dc5aa6017..7a6b3cae21 100644 --- a/src/routes/docs/products/storage/quick-start/+page.markdoc +++ b/src/routes/docs/products/storage/quick-start/+page.markdoc @@ -127,7 +127,7 @@ To upload a file, add this to your app. For web apps, you can use the File objec const storage = new Storage(client); const promise = storage.createFile( - '[BUCKET_ID]', + '', ID.unique(), { name: 'image.jpg', From 7c2af2acf1e265c801db153c84abe85f9a3ec2e6 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:19:18 +0100 Subject: [PATCH 04/10] Update src/routes/docs/products/storage/quick-start/+page.markdoc Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/routes/docs/products/storage/quick-start/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/products/storage/quick-start/+page.markdoc b/src/routes/docs/products/storage/quick-start/+page.markdoc index 7a6b3cae21..523d8bd104 100644 --- a/src/routes/docs/products/storage/quick-start/+page.markdoc +++ b/src/routes/docs/products/storage/quick-start/+page.markdoc @@ -281,7 +281,7 @@ const client = new Client() const storage = new Storage(client); -const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); +const result = storage.getFileDownload('', ''); console.log(result); // Resource URL ``` From c14b89955967186220f36831368caae05b6c4c41 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:19:33 +0100 Subject: [PATCH 05/10] Update src/routes/docs/products/storage/upload-download/+page.markdoc Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- .../docs/products/storage/upload-download/+page.markdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index eefec1c68b..e6aa5ac14b 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -728,8 +728,8 @@ const client = new Client() const storage = new Storage(client); const result = storage.getFilePreview( - '[BUCKET_ID]', - '[FILE_ID]', + '', + '', 200, // width 200, // height ImageGravity.Center, // gravity From 6cb934184133eb5eddf49a1d03b1d07d296e161e Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:19:39 +0100 Subject: [PATCH 06/10] Update src/routes/docs/products/storage/upload-download/+page.markdoc Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/routes/docs/products/storage/upload-download/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index e6aa5ac14b..786bfeaac2 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -851,7 +851,7 @@ const client = new Client() const storage = new Storage(client); -const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]'); +const result = storage.getFileView('', ''); console.log(result); // Resource URL ``` From 0b4fa21c9f0690a14fde447469aef5ca56ce9406 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:19:49 +0100 Subject: [PATCH 07/10] Update src/routes/docs/products/storage/upload-download/+page.markdoc Co-authored-by: Steven Nguyen <1477010+stnguyen90@users.noreply.github.com> --- src/routes/docs/products/storage/upload-download/+page.markdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index 786bfeaac2..ae9900ddaa 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -611,7 +611,7 @@ const client = new Client() const storage = new Storage(client); -const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); +const result = storage.getFileDownload('', ''); console.log(result); // Resource URL ``` From f1a9c75713d8795a5ec5ee362991b66e11e96d08 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:22:51 +0100 Subject: [PATCH 08/10] Use consistent placeholder format --- .../storage/upload-download/+page.markdoc | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index ae9900ddaa..2a048191d9 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -25,7 +25,7 @@ You can also upload files programmatically using our SDKs: const storage = new Storage(client); const promise = storage.createFile( - '[BUCKET_ID]', + '', ID.unique(), document.getElementById('uploader').files[0] ); @@ -50,11 +50,11 @@ You can also upload files programmatically using our SDKs: // If running in a browser environment, you can use File directly const browserFile = new File(['hello'], 'hello.txt'); - await storage.createFile('[BUCKET_ID]', ID.unique(), browserFile); + await storage.createFile('', ID.unique(), browserFile); // If running in Node.js, use InputFile const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg'); - await storage.createFile('[BUCKET_ID]', ID.unique(), nodeFile); + await storage.createFile('', ID.unique(), nodeFile); ``` ```client-flutter @@ -68,7 +68,7 @@ You can also upload files programmatically using our SDKs: final storage = Storage(client); final file = await storage.createFile( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: ID.unique(), file: InputFile.fromPath(path: './path-to-files/image.jpg', filename: 'image.jpg'), ); @@ -87,7 +87,7 @@ You can also upload files programmatically using our SDKs: val storage = Storage(client) val file = storage.createFile( - bucketId = "[BUCKET_ID]", + bucketId = "", fileId = ID.unique(), file = File("./path-to-files/image.jpg"), ) @@ -132,7 +132,7 @@ You can also upload files programmatically using our SDKs: let storage = Storage(client) let file = try await storage.createFile( - bucketId: "[BUCKET_ID]", + bucketId: "", fileId: ID.unique(), file: InputFile.fromBuffer(yourByteBuffer, filename: "image.jpg", @@ -151,7 +151,7 @@ You can also upload files programmatically using our SDKs: --cec8e8123c05ba25 Content-Disposition: form-data; name="operations" - { "query": "mutation CreateFile($bucketId: String!, $fileId: String!, $file: InputFile!) { storageCreateFile(bucketId: $bucketId, fileId: $fileId, file: $file) { id } }", "variables": { "bucketId": "[BUCKET_ID]", "fileId": "[FILE_ID]", "file": null } } + { "query": "mutation CreateFile($bucketId: String!, $fileId: String!, $file: InputFile!) { storageCreateFile(bucketId: $bucketId, fileId: $fileId, file: $file) { id } }", "variables": { "bucketId": "", "fileId": "[FILE_ID]", "file": null } } --cec8e8123c05ba25 Content-Disposition: form-data; name="map" @@ -185,7 +185,7 @@ For example, for the input tag ``, you would ca ```js const promise = storage.createFile( - '[BUCKET_ID]', + '', ID.unique(), document.getElementById('uploader').files[0] ); @@ -391,7 +391,7 @@ client .setProject('') // Your project ID ; -const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]'); +const promise = storage.getFile('', '[FILE_ID]'); promise.then(function (response) { console.log(response); // Success @@ -412,7 +412,7 @@ void main() { // Init SDK ; // downloading file Future result = storage.getFile( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ).then((bytes) { final file = File('path_to_file/filename.ext'); @@ -425,7 +425,7 @@ void main() { // Init SDK //displaying image preview FutureBuilder( future: storage.getFile( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { @@ -448,7 +448,7 @@ func main() async throws { let storage = Storage(client) let byteBuffer = try await storage.getFile( - bucketId: "[BUCKET_ID]", + bucketId: "", fileId: "[FILE_ID]" ) @@ -475,7 +475,7 @@ class MainActivity : AppCompatActivity() { val storage = Storage(client) val result = storage.getFile( - bucketId = "[BUCKET_ID]", + bucketId = "", fileId = "[FILE_ID]" ) println(result); // Resource URL @@ -491,7 +491,7 @@ const client = new Client() const storage = new Storage(client); -const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]'); +const promise = storage.getFile('', '[FILE_ID]'); promise.then(function (response) { console.log(response); // Success @@ -517,7 +517,7 @@ client .setProject('') // Your project ID ; -const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]'); +const result = storage.getFileDownload('', '[FILE_ID]'); console.log(result); // Resource URL ``` @@ -534,7 +534,7 @@ void main() { // Init SDK ; // downloading file Future result = storage.getFileDownload( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ).then((bytes) { final file = File('path_to_file/filename.ext'); @@ -547,7 +547,7 @@ void main() { // Init SDK //displaying image preview FutureBuilder( future: storage.getFileDownload( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { @@ -568,7 +568,7 @@ func main() async throws { .setProject("") // Your project ID let storage = Storage(client) let byteBuffer = try await storage.getFileDownload( - bucketId: "[BUCKET_ID]", + bucketId: "", fileId: "[FILE_ID]" ) @@ -595,7 +595,7 @@ class MainActivity : AppCompatActivity() { val storage = Storage(client) val result = storage.getFileDownload( - bucketId = "[BUCKET_ID]", + bucketId = "", fileId = "[FILE_ID]" ) println(result); // Resource URL @@ -633,7 +633,7 @@ client .setProject('') // Your project ID ; -const result = storage.getFilePreview('[BUCKET_ID]', '[FILE_ID]'); +const result = storage.getFilePreview('', '[FILE_ID]'); console.log(result); // Resource URL ``` @@ -650,7 +650,7 @@ void main() { // Init SDK ; // downloading file Future result = storage.getFilePreview( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ).then((bytes) { final file = File('path_to_file/filename.ext'); @@ -663,7 +663,7 @@ void main() { // Init SDK //displaying image preview FutureBuilder( future: storage.getFilePreview( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { @@ -684,7 +684,7 @@ func main() async throws { .setProject("") // Your project ID let storage = Storage(client) let byteBuffer = try await storage.getFilePreview( - bucketId: "[BUCKET_ID]", + bucketId: "", fileId: "[FILE_ID]" ) @@ -711,7 +711,7 @@ class MainActivity : AppCompatActivity() { val storage = Storage(client) val result = storage.getFilePreview( - bucketId = "[BUCKET_ID]", + bucketId = "", fileId = "[FILE_ID]" ) println(result); // Resource URL @@ -757,7 +757,7 @@ client .setProject('') // Your project ID ; -const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]'); +const result = storage.getFileView('', '[FILE_ID]'); console.log(result); // Resource URL ``` @@ -774,7 +774,7 @@ void main() { // Init SDK ; // downloading file Future result = storage.getFileView( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ).then((bytes) { final file = File('path_to_file/filename.ext'); @@ -787,7 +787,7 @@ void main() { // Init SDK //displaying image preview FutureBuilder( future: storage.getFileView( - bucketId: '[BUCKET_ID]', + bucketId: '', fileId: '[FILE_ID]', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { @@ -808,7 +808,7 @@ func main() async throws { .setProject("") // Your project ID let storage = Storage(client) let byteBuffer = try await storage.getFileView( - bucketId: "[BUCKET_ID]", + bucketId: "", fileId: "[FILE_ID]" ) @@ -835,7 +835,7 @@ class MainActivity : AppCompatActivity() { val storage = Storage(client) val result = storage.getFileView( - bucketId = "[BUCKET_ID]", + bucketId = "", fileId = "[FILE_ID]" ) println(result); // Resource URL From c3cb6463f77077cf9071d3aa3a810bd5dcf9c0a4 Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:24:42 +0100 Subject: [PATCH 09/10] Use consistent placeholder format --- .../storage/upload-download/+page.markdoc | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/routes/docs/products/storage/upload-download/+page.markdoc b/src/routes/docs/products/storage/upload-download/+page.markdoc index 2a048191d9..44e4ee05ea 100644 --- a/src/routes/docs/products/storage/upload-download/+page.markdoc +++ b/src/routes/docs/products/storage/upload-download/+page.markdoc @@ -146,12 +146,12 @@ You can also upload files programmatically using our SDKs: POST /v1/storage/buckets/{bucketId}/files HTTP/1.1 Content-Type: multipart/form-data; boundary="cec8e8123c05ba25" Content-Length: *Length of your entity body in bytes* - X-Appwrite-Project: [PROJECT_ID] + X-Appwrite-Project: --cec8e8123c05ba25 Content-Disposition: form-data; name="operations" - { "query": "mutation CreateFile($bucketId: String!, $fileId: String!, $file: InputFile!) { storageCreateFile(bucketId: $bucketId, fileId: $fileId, file: $file) { id } }", "variables": { "bucketId": "", "fileId": "[FILE_ID]", "file": null } } + { "query": "mutation CreateFile($bucketId: String!, $fileId: String!, $file: InputFile!) { storageCreateFile(bucketId: $bucketId, fileId: $fileId, file: $file) { id } }", "variables": { "bucketId": "", "fileId": "", "file": null } } --cec8e8123c05ba25 Content-Disposition: form-data; name="map" @@ -391,7 +391,7 @@ client .setProject('') // Your project ID ; -const promise = storage.getFile('', '[FILE_ID]'); +const promise = storage.getFile('', ''); promise.then(function (response) { console.log(response); // Success @@ -413,7 +413,7 @@ void main() { // Init SDK // downloading file Future result = storage.getFile( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ).then((bytes) { final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes) @@ -426,7 +426,7 @@ void main() { // Init SDK FutureBuilder( future: storage.getFile( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { return snapshot.hasData && snapshot.data != null @@ -449,7 +449,7 @@ func main() async throws { let byteBuffer = try await storage.getFile( bucketId: "", - fileId: "[FILE_ID]" + fileId: "" ) print(String(describing: byteBuffer) @@ -476,7 +476,7 @@ class MainActivity : AppCompatActivity() { val result = storage.getFile( bucketId = "", - fileId = "[FILE_ID]" + fileId = "" ) println(result); // Resource URL } @@ -491,7 +491,7 @@ const client = new Client() const storage = new Storage(client); -const promise = storage.getFile('', '[FILE_ID]'); +const promise = storage.getFile('', ''); promise.then(function (response) { console.log(response); // Success @@ -517,7 +517,7 @@ client .setProject('') // Your project ID ; -const result = storage.getFileDownload('', '[FILE_ID]'); +const result = storage.getFileDownload('', ''); console.log(result); // Resource URL ``` @@ -535,7 +535,7 @@ void main() { // Init SDK // downloading file Future result = storage.getFileDownload( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ).then((bytes) { final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes) @@ -548,7 +548,7 @@ void main() { // Init SDK FutureBuilder( future: storage.getFileDownload( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { return snapshot.hasData && snapshot.data != null @@ -569,7 +569,7 @@ func main() async throws { let storage = Storage(client) let byteBuffer = try await storage.getFileDownload( bucketId: "", - fileId: "[FILE_ID]" + fileId: "" ) print(String(describing: byteBuffer)) @@ -596,7 +596,7 @@ class MainActivity : AppCompatActivity() { val result = storage.getFileDownload( bucketId = "", - fileId = "[FILE_ID]" + fileId = "" ) println(result); // Resource URL } @@ -633,7 +633,7 @@ client .setProject('') // Your project ID ; -const result = storage.getFilePreview('', '[FILE_ID]'); +const result = storage.getFilePreview('', ''); console.log(result); // Resource URL ``` @@ -651,7 +651,7 @@ void main() { // Init SDK // downloading file Future result = storage.getFilePreview( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ).then((bytes) { final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes) @@ -664,7 +664,7 @@ void main() { // Init SDK FutureBuilder( future: storage.getFilePreview( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { return snapshot.hasData && snapshot.data != null @@ -685,7 +685,7 @@ func main() async throws { let storage = Storage(client) let byteBuffer = try await storage.getFilePreview( bucketId: "", - fileId: "[FILE_ID]" + fileId: "" ) print(String(describing: byteBuffer)) @@ -712,7 +712,7 @@ class MainActivity : AppCompatActivity() { val result = storage.getFilePreview( bucketId = "", - fileId = "[FILE_ID]" + fileId = "" ) println(result); // Resource URL } @@ -757,7 +757,7 @@ client .setProject('') // Your project ID ; -const result = storage.getFileView('', '[FILE_ID]'); +const result = storage.getFileView('', ''); console.log(result); // Resource URL ``` @@ -775,7 +775,7 @@ void main() { // Init SDK // downloading file Future result = storage.getFileView( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ).then((bytes) { final file = File('path_to_file/filename.ext'); file.writeAsBytesSync(bytes) @@ -788,7 +788,7 @@ void main() { // Init SDK FutureBuilder( future: storage.getFileView( bucketId: '', - fileId: '[FILE_ID]', + fileId: '', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { return snapshot.hasData && snapshot.data != null @@ -809,7 +809,7 @@ func main() async throws { let storage = Storage(client) let byteBuffer = try await storage.getFileView( bucketId: "", - fileId: "[FILE_ID]" + fileId: "" ) print(String(describing: byteBuffer)) @@ -836,7 +836,7 @@ class MainActivity : AppCompatActivity() { val result = storage.getFileView( bucketId = "", - fileId = "[FILE_ID]" + fileId = "" ) println(result); // Resource URL } From 3557c854d212d7c31471a98494034bee3b84496e Mon Sep 17 00:00:00 2001 From: Ebenezer Don Date: Tue, 29 Apr 2025 23:27:16 +0100 Subject: [PATCH 10/10] Use consistent placeholder format --- src/routes/docs/products/storage/images/+page.markdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/docs/products/storage/images/+page.markdoc b/src/routes/docs/products/storage/images/+page.markdoc index 4436e85b11..2253727599 100644 --- a/src/routes/docs/products/storage/images/+page.markdoc +++ b/src/routes/docs/products/storage/images/+page.markdoc @@ -106,8 +106,8 @@ void main() { // Init SDK //displaying image preview FutureBuilder( future: storage.getFilePreview( - bucketId: '[BUCKET_ID]', - fileId: '[FILE_ID]', + bucketId: '', + fileId: '', ), //works for both public file and private file, for private files you need to be logged in builder: (context, snapshot) { return snapshot.hasData && snapshot.data != null