
here is the my code export const uploadPDF = async (pdf) => { try { console.log("Uploading file:", pdf);
const file = pdf.assets[0];
console.log("Uploading file:", file);
const result = await storage.createFile(
process.env.EXPO_PUBLIC_APPWRITE_BOOKSHOP_BUCKET_ID,
ID.unique(),
file
);
if (!result || !result.$id) {
throw new Error("Failed to upload PDF");
}
const pdfUri = `${process.env.EXPO_PUBLIC_APPWRITE_ENDPOINT}/storage/buckets/${process.env.EXPO_PUBLIC_APPWRITE_BOOKSHOP_BUCKET_ID}/files/${result.$id}/view?project=${process.env.EXPO_PUBLIC_APPWRITE_PROJECT_ID}`;
console.log("✅ PDF uploaded successfully:", pdfUri);
return pdfUri;
} catch (error) { console.error("❌ Error uploading PDF:", error); if (error.response) { console.error("Response:", error.response); } throw error; } };
and here are the logs
(NOBRIDGE) LOG Uploading file: {"assets": [{"mimeType": "application/pdf", "name": "Basic Real Analysis_ Along with a companion volume Advanced Real Analysis ( PDFDrive ).pdf", "size": 5292034, "uri": "file:///data/user/0/host.exp.exponent/cache/DocumentPicker/6081f92f-334d-413f-900e-17f166e15a23.pdf"}], "canceled": false} (NOBRIDGE) LOG Uploading file: {"mimeType": "application/pdf", "name": "Basic Real Analysis_ Along with a companion volume Advanced Real Analysis ( PDFDrive ).pdf", "size": 5292034, "uri": "file:///data/user/0/host.exp.exponent/cache/DocumentPicker/6081f92f-334d-413f-900e-17f166e15a23.pdf"} (NOBRIDGE) ERROR ❌ Error uploading PDF: [AppwriteException: Network request failed]
Recommended threads
- How many functions can I run simultaneou...
I want to konw, how many functions can I can simultaneously in appwrite cloud? I want to make a chat app where user sends text and text is processed using funct...
- security question
hello i got a small question, is this code secured, is there something that should not be displayed on the client, i am talking about the image tag: my code: ...
- can not signup user
When I try to sign up a user, it says user already exists, but I can not see anyone on my cloud console.. I have also tried to refrsh and everything. Please hel...
