
Hi there, I am getting a weird error where my file creation is timing out. Maybe I have the wrong syntax, but I tried to follow the documentation.
TypeScript
// Download the image directly as a stream
const imageResponse = await axios.get(output, { responseType: "arraybuffer", timeout: 10000}); // Use arraybuffer for compatibility
// Convert the array buffer to a Buffer
const imageBuffer = Buffer.from(imageResponse.data);
// Upload the image to Appwrite storage directly
const createFile = await storage.createFile(
config.bucketId, // Replace with your Appwrite storage bucket ID
ID.unique(), // Generate a unique file ID
imageBuffer, // Pass the stream directly
["user:" + account_id] // Set user-specific permissions (read/write access)
);
// Save metadata in Appwrite database
const metadata = {
account_id: account_id, // The user's account ID
file_id: createFile.$id, // File ID in Appwrite
userPrompt: additionalUserPrompt, // Store the prompt for reference
};
// Create MetaData entry
const createReplicateMetadataDocument = await databases.createDocument(
config.databaseId,
config.replicateMetadataId, // Replace with your Appwrite database collection ID
ID.unique(), // Generate a unique document ID
metadata
);
TL;DR
Developers are facing a timeout issue while creating a file due to an error in the code. The error points to a problem with the 'Storage.createFile' function. The issue arises from passing the imageBuffer to the storage.createFile function. The code needs to be revised to resolve this error.
and here is the error from the function execution:
TypeScript
Error calling Replicate: TypeError: Cannot read properties of undefined (reading 'Symbol(Symbol.asyncIterator)')
at Storage.createFile (/usr/local/server/src/function/node_modules/node-appwrite/lib/services/storage.js:404:40)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Module.default (file:///usr/local/server/src/function/src/main.js:76:24)
at async execute (/usr/local/server/src/server.js:208:16)
at async action (/usr/local/server/src/server.js:225:7)
at async /usr/local/server/src/server.js:14:5
The error is happening around 14s so it isn't the 30s timeout causing it. Anybody have ideas? Thanks.
Recommended threads
- account.get imageUrl
We dont get imageUrl of users when do account.get(), i need to manually fetch,and set it. but this should be default behaviour.
- unexpected row_invalid_structure error
In images you can see both my code,error, column schema I do have timezone in table schema but still while creating a row i am receving row_invalid_structure e...
- invalid document structure
This doesn't exist, and I cannot create it. Please help, this happens if I try to edit a user's data or create a new profile on Appwrite or the app
