Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert a single file (.txt / .pdf / .xls) to a zip file from a specific path. #284

Closed
vinayn-simelabs opened this issue Aug 18, 2023 · 1 comment

Comments

@vinayn-simelabs
Copy link

vinayn-simelabs commented Aug 18, 2023

Is there a way to convert a single file which can be any format say PDF, Txt, or Xls to a zip file using this plugin ? I've tried but it is showing "Cannot read proper zipFolder of null or zipFiles of null". I'm using RN fetch blob to create a PDF file.

let pdfLocation =
             Platform.OS == "ios"
               ? `${RNFetchBlob.fs.dirs.DocumentDir}/Barcode-labels.zip`
               : RNFetchBlob.fs.dirs.DownloadDir + "/Barcode-labels.zip";
           RNFetchBlob.fs.createFile(
             pdfLocation,
             res?.data?.data?.zebraCodeTxtFile,
             "base64"
           );
           console.log("Response: ", pdfLocation, res.data);

           zip(
             Platform.OS == "ios"
               ? [RNFetchBlob.fs.dirs.DocumentDir + "/"]
               : RNFetchBlob.fs.dirs.DownloadDir + "/",
             pdfLocation
           )
             .then((path) => {
               console.log(`zip completed at ${path}`);
             })
             .catch((error) => {
               console.error(error);
             })
@plrthink
Copy link
Collaborator

You should use zip(pdfLocation, dir) since the first argument is the zip not the target path.

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

No branches or pull requests

2 participants