Skip to content

Conversation

suhasdeshpande
Copy link
Contributor

@suhasdeshpande suhasdeshpande commented Sep 17, 2025

Summary by CodeRabbit

  • Documentation
    • Updated Storage Quick Start examples to consistently use ID-based file generation across client and server samples.
    • Clarified client and Node.js snippets to match their respective SDK usage.
    • Removed a browser-specific create-file snippet to streamline the multi-language examples and reduce duplication.

Copy link
Contributor

coderabbitai bot commented Sep 17, 2025

Walkthrough

The docs file src/routes/docs/products/storage/quick-start/+page.markdoc was updated: the client-web create-file example now imports ID from "appwrite" and uses it for fileId; the server-nodejs example uses the module alias sdk.ID.unique() for fileId; a browser-specific snippet that created a File directly was removed. No other functional changes were made to code blocks or flow.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add ID import to storage quick start examples" is concise and accurately reflects the main change in the PR—adding the ID import and updating the storage quick-start examples as described in the summary. It communicates the primary intent clearly and is appropriate for someone scanning the repository history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch suhas/fix-doc

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2d71fb and 0cb120f.

📒 Files selected for processing (1)
  • src/routes/docs/products/storage/quick-start/+page.markdoc (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/routes/docs/products/storage/quick-start/+page.markdoc
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (3)
src/routes/docs/products/storage/quick-start/+page.markdoc (3)

49-53: Standardize Cloud endpoint to include region.

Other examples use https://.cloud.appwrite.io/v1. Align Node sample for consistency and fewer 301/geo issues.

Apply this diff:

-    .setEndpoint('https://cloud.appwrite.io/v1')
+    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')

113-116: Android: import Context (used below).

Apply this diff:

 import io.appwrite.Client
 import io.appwrite.services.Storage
 import io.appwrite.ID
+import android.content.Context

226-228: Flutter download: add missing semicolon after writeAsBytesSync.

Small syntax fix.

Apply this diff:

-    file.writeAsBytesSync(bytes)
+    file.writeAsBytesSync(bytes);

Additionally, add import 'dart:io'; at the top of this snippet so File resolves.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c176f80 and a2d71fb.

📒 Files selected for processing (1)
  • src/routes/docs/products/storage/quick-start/+page.markdoc (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: tests
🔇 Additional comments (4)
src/routes/docs/products/storage/quick-start/+page.markdoc (4)

23-23: Good call adding ID import to web example.

Makes the ID.unique() usage explicit and copy‑pasteable.


94-110: Swift sample looks correct.

API usage and async/await are consistent.


159-180: HTTP multipart example: LGTM.

Headers, operations/map, and file part look correct.


303-306: React Native download: object-params confirmed — no change required.

Appwrite React Native docs use an object signature for Storage.getFileDownload (bucketId, fileId, optional token); the snippet in src/routes/docs/products/storage/quick-start/+page.markdoc lines 303–306 already matches.

Comment on lines 56 to 71
// If running in a browser environment, you can use File directly
const browserFile = new File(['hello'], 'hello.txt');
await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: browserFile
});

```server-nodejs
const sdk = require('node-appwrite');
const { InputFile } = require('node-appwrite/file');
// If running in Node.js, use InputFile
const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg');
await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: nodeFile
});
```
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix CommonJS top‑level await and remove browser‑only File usage in server‑nodejs block.

Top‑level await is invalid with require(); and File(['...']) is browser‑only. Keep the Node path using InputFile and wrap in an async IIFE.

Apply this diff:

-// If running in a browser environment, you can use File directly
-const browserFile = new File(['hello'], 'hello.txt');
-await storage.createFile({
-  bucketId: '<BUCKET_ID>',
-  fileId: ID.unique(),
-  file: browserFile
-});
-
-// If running in Node.js, use InputFile
-const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg');
-await storage.createFile({
-  bucketId: '<BUCKET_ID>',
-  fileId: ID.unique(),
-  file: nodeFile
-});
+(async () => {
+  // Node.js: use InputFile
+  const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg');
+  const response = await storage.createFile({
+    bucketId: '<BUCKET_ID>',
+    fileId: ID.unique(),
+    file: nodeFile
+  });
+  console.log(response);
+})().catch(console.error);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// If running in a browser environment, you can use File directly
const browserFile = new File(['hello'], 'hello.txt');
await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: browserFile
});
```server-nodejs
const sdk = require('node-appwrite');
const { InputFile } = require('node-appwrite/file');
// If running in Node.js, use InputFile
const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg');
await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: nodeFile
});
```
(async () => {
// Node.js: use InputFile
const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg');
const response = await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: nodeFile
});
console.log(response);
})().catch(console.error);
🤖 Prompt for AI Agents
In src/routes/docs/products/storage/quick-start/+page.markdoc around lines 56 to
71, the example mixes a browser-only File constructor and uses top-level await
which breaks in CommonJS; remove the browser File example from the
server/Node.js section, keep the InputFile.fromPath usage, and wrap the async
call in an immediately-invoked async function (async () => { ... })() so there
is no top-level await; ensure the code block demonstrates only the Node.js
approach with InputFile.fromPath and await inside the IIFE.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@suhasdeshpande this is a valid review, seems like we are showing browser file in nodejs block

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment on lines 76 to 89
void main() { // Init SDK
final client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');

// If running in a browser environment, you can use File directly
const browserFile = new File(['hello'], 'hello.txt');
await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: browserFile
});
final storage = Storage(client);

// If running in Node.js, use InputFile
const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg');
await storage.createFile({
final file = await storage.createFile(
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: nodeFile
});
```
file: InputFile.fromPath(path: './path-to-files/image.jpg', filename: 'image.jpg'),
);
}
```
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Flutter: make main async before using await.

Current snippet won’t compile as written.

Apply this diff:

-void main() { // Init SDK
+Future<void> main() async { // Init SDK
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
void main() { // Init SDK
final client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
// If running in a browser environment, you can use File directly
const browserFile = new File(['hello'], 'hello.txt');
await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: browserFile
});
final storage = Storage(client);
// If running in Node.js, use InputFile
const nodeFile = InputFile.fromPath('/path/to/file.jpg', 'file.jpg');
await storage.createFile({
final file = await storage.createFile(
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: nodeFile
});
```
file: InputFile.fromPath(path: './path-to-files/image.jpg', filename: 'image.jpg'),
);
}
```
Future<void> main() async { // Init SDK
final client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
final storage = Storage(client);
final file = await storage.createFile(
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: InputFile.fromPath(path: './path-to-files/image.jpg', filename: 'image.jpg'),
);
}
🤖 Prompt for AI Agents
In src/routes/docs/products/storage/quick-start/+page.markdoc around lines 76 to
89, the Flutter snippet uses await inside main but declares it as a synchronous
void function; change the signature to an asynchronous main (e.g., Future<void>
main() async) so await is valid, and ensure any necessary async imports (if not
already present) are included so the snippet compiles.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@suhasdeshpande valid as well, main is not async

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment on lines 141 to 150
const promise = storage.createFile(
'<BUCKET_ID>',
ID.unique(),
{
name: 'image.jpg',
type: 'image/jpeg',
size: 1234567,
uri: 'file:///path/to/file.jpg',
}
);
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

React Native signature parity: confirm tuple vs object style.

Other JS SDKs use object params; RN here uses positional args. Verify the installed react-native-appwrite version and align the snippet accordingly.


🌐 Web query:

Does the latest react-native-appwrite Storage.createFile accept object parameters ({ bucketId, fileId, file }) or positional (bucketId, fileId, file)? Cite official docs and show the recommended example.

💡 Result:

Short answer: The current react-native-appwrite SDK uses an options object (named parameters). Example from the official React Native docs shows createFile({ bucketId, fileId, file, permissions }). [1] An older (1.5.x) docs page used positional args (bucketId, fileId, file). [2]

Recommended example (from official React Native docs):
const result = await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: '<FILE_ID>',
file: await pickSingle(),
permissions: ["read('any')"]
});
console.log(result);. [1]

Sources:
[1] Appwrite — Client React Native Storage (createFile example). (appwrite.io)
[2] Appwrite 1.5.x — Client React Native Storage (positional example). (appwrite.io)

Citations:


Update React Native example to use named (options) parameters

Replace the positional-argument example in src/routes/docs/products/storage/quick-start/+page.markdoc (lines 141–150) with the React Native SDK signature that accepts an options object — e.g.:

const result = await storage.createFile({
bucketId: '<BUCKET_ID>',
fileId: ID.unique(),
file: await pickSingle(),
permissions: ["read('any')"]
});

🤖 Prompt for AI Agents
In src/routes/docs/products/storage/quick-start/+page.markdoc around lines 141
to 150, replace the positional-argument React Native example with the SDK's
named options signature: call storage.createFile with a single options object
containing bucketId, fileId (e.g., ID.unique()), file (e.g., await pickSingle()
for RN), and any permissions array (e.g., ["read('any')"]); make the example use
await to capture the result and rename the variable to result to match the
example in the comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@suhasdeshpande please fix this too, we shifted to using option params everywhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants