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
- ACTIVATE DEPLOYMENT PROBLEM...
It's not giving me the option to activate a deployment that says it's ready..
- Auth working for emulator but not for ph...
hey guys i'm using appwrite for expo react native it is working perfectly for emulator but does not working for physical devices can u explain any one and it is...
- general_unauthorized_scope
localhost oauth not working. general_unauthorized_scope error showing. { "message": "User (role: guests) missing scopes ([\"account\"])", "code": 401, ...