Ugo_Augustus
Ugo_Augustus6mo ago

url to pdf node not working (same for generated epub files)

I tried to generate epub files from text input, store them to GCP and return a download link, but it wouldn’t work especially because of the file path. I had to back track and try out the url to pdf file converter and the html to pdf converter nodes you have on your platform both have the same problem. They’re simply not working. I’ve tried several times to use AI to generate a node that works but still it doesn’t work. You have templates for converting from firestore to pdf but none for epub, and when I try using the epub-gen node dependency, it throws a file path error, or outputs a path I do not know where to locate. If you can provide me with a guide on this it would be really helpful.
Solution:
Hi @Ugo101, could you please share the api reference you are following for epub upload files? Ideally the path should be the bucket should be: process.env.BUCKET, I would recommend to refer to the implementation for the already present GCP Storage nodes. cc @Luis, maybe we can have a template for this, a suggestion....
Jump to solution
13 Replies
Solution
Gaurav Chadha
Gaurav Chadha6mo ago
Hi @Ugo101, could you please share the api reference you are following for epub upload files? Ideally the path should be the bucket should be: process.env.BUCKET, I would recommend to refer to the implementation for the already present GCP Storage nodes. cc @Luis, maybe we can have a template for this, a suggestion.
Luis
Luis6mo ago
Yup I'll hop on this, will post updates here.
Gaurav Chadha
Gaurav Chadha6mo ago
Thanks. 🙌
Ugo_Augustus
Ugo_Augustus6mo ago
Hi, I used an empty node for the epub generation. These are some of the errors I been getting and sample code I have used. ERROR MESSAGES: { "error": { "nodeId": "test-node-f8cee0....d", "nodeName": "Empty node", "stage": "installing dependencies", "errorObject": { "code": 1, "killed": false, "signal": null, "cmd": "npm install epub-gen @google-cloud/storage@7.10.0 uuid@9.0.1 fs@0.0.2 path@0.12.7 node-epub-gen epub@1.2.1" } }, "buildId": "1713432..." } { "error": "fn.default.default is not a function" } { "error": "ENOENT: no such file or directory, open '/usr/src/app/bucket/builtNodes/templates/template.css'" } CODE: import Epub from 'epub-gen'; import EPUB from 'epub'; import { Storage } from '@google-cloud/storage'; import { v4 as uuidv4 } from 'uuid'; import { writeFileSync, readFileSync } from 'fs'; import { join } from 'path'; async function generateEpubAndUploadFirestoreData({ title, author, content }) { const fileName = ${uuidv4()}.epub; const epubFilePath = join("mak8.appspot.com/uploads", fileName); // Create a new EPUB book const book = new EPUB(epubFilePath, { title: title, author: author }); // Add a section book.addSection('Chapter 1', content); // Generate EPUB await new Promise((resolve, reject) => { book.generate((error, buffer) => { if (error) reject(error); else resolve(buffer); }); }); // Upload to Google Cloud Storage try { const storage = new Storage(); const bucket = storage.bucket("mak8.appspot.com"); const file = bucket.file(fileName); await file.save(readFileSync(epubFilePath), { resumable: false }); await file.makePublic(); const downloadURL = https://storage.googleapis.com/${bucket.name}/${fileName}; console.log('EPUB uploaded and accessible at:', downloadURL); return downloadURL; } catch (error) { console.error('Error uploading EPUB to GCP:', error); throw error; } } If you can suggest a possible solution or alternative, would be appreciated. @Luis were you able to develop any custom node that converts from text to epub?
Luis
Luis6mo ago
Hey @Ugo101, I'm working on a node for this, running into the same error as well. But I'll share with you here once its working and a full template as well.
Ugo_Augustus
Ugo_Augustus6mo ago
Eagerly looking forward to it
Luis
Luis6mo ago
Hi, can you copy this workflow into your project. It generates an epub from given options, and chapters. And then returns a download url of the epub. I've added some sample input, so to try it out all you need to do is ship and test.
Luis
Luis6mo ago
Added as a template too, probably easier to get started there.
No description
Ugo_Augustus
Ugo_Augustus6mo ago
Hi, @Luis, thank you for the great job you did with the Epub Generator, I just checked it out now and saw you included a lot of cool features to it. I tried it out and got an output in this format: 248ea0f9-ff4a-481c-8aee-4012c255a046.epub I want to know where and how to view such output, where it is being saved. Also, this line:
const writePath = path.join(process.env.BUCKET_FOLDER_PATH, outputPath),  does it point to mine or Buildship’s google storage bucket? If none, which folder path is it referencing? Because the aim is to make the Epub url publicly accessible.
Luis
Luis6mo ago
Yeah it stores it on your BuildShip storage bucket and returns the publicly accessible url that you and others can use. Then you can download the epub and open it with any ebook reader of your choice
Ugo_Augustus
Ugo_Augustus6mo ago
@Luis , Yes, I see that the epub is being saved to my Buildship storage, and I can click on the download button from the storage and it saves into my laptop. My question now is this: This output format that is returned: 80a5d-b6b1-482c-bf6a-0f8e469ef514.epub I have tried pasting it on the browser to see if it will download the epub to my laptop, but the browser didn't recognize it as a publicly accessible link. so, when you said it returns a publicly accessible url, did you mean this or something else, because this is the only output that is returned. 80a5d-b6b1-482c-bf6a-0f8e469ef514.epub
Gaurav Chadha
Gaurav Chadha6mo ago
Hi, @Ugo101, The template generate a public url which you'll require to paste in the browser, if you have already downloaded it from the storage then it is already present in your system, not required to paste the epub file to browser. The publicly accessible URL is the one generated by the template.
No description
Ugo_Augustus
Ugo_Augustus5mo ago
Really appreciate the work you did here. I look forward to working with you guys more in the near future. And I will continue to bring more of my clients to the Buildship platform and community. Love you guys ❤️