wubzz / pdf-merge

Merge multiple PDF Files into a single PDF document
127 stars 32 forks source link

Don't run to merge in AWS S3. #11

Closed youngcademy closed 7 years ago

youngcademy commented 7 years ago

I have a source below.

.then(() => {

            var files = re.map(u => {
              var name_arr = u.label_url.split("/");
              return tempDir + "/" + name_arr[name_arr.length - 1];
            });

            var pdfMerge = new PDFMerge(files, pdftkPath);
            console.log("================= files START");
            console.log(files);
            console.log("================= files END");
            console.log("================= pdftkPath START");
            console.log(pdftkPath);
            console.log("================= pdftkPath END");
            console.log("================= pdfMerge START");
            console.log(pdfMerge);
            console.log("================= pdfMerge END");

            return pdfMerge
              .asReadStream()
              .promise()
              .then(function(readStream){
                console.log("================= readStream START");
                console.log(readStream);
                console.log("================= readStream END");
                console.log("================= readStream.path START");
                console.log(readStream.path);
                console.log("================= readStream.path END");
                var split_arr = readStream.path.split("/");
                mergePdfTempFile = readStream.path;
                console.log("================= mergePdfTempFile START");
                console.log(mergePdfTempFile);
                console.log("================= mergePdfTempFile END");

                return api.storage.pdfUploadS3(
                  api.userInfo.account_id,
                  "",
                  "",
                  readStream.path,
                  split_arr[split_arr.length - 1] + ".pdf"
                )
              })
          })

and Error souce is below.

/var/app/current/lib/pdftk-bin/vendor/linux/x64/pdftk ================= tempDir START /tmp/117213-448-1y9pd1q ================= tempDir END ================= files START [ '/tmp/117213-448-1y9pd1q/79953eb0-d5ba-40d7-9573-e10ba95124e5-1489414415284564.pdf' ] ================= files END ================= pdftkPath START /var/app/current/lib/pdftk-bin/vendor/linux/x64/pdftk ================= pdftkPath END ================= pdfMerge START PDFMerge { pdftkPath: '/var/app/current/lib/pdftk-bin/vendor/linux/x64/pdftk', pdfFiles: [ '/tmp/117213-448-1y9pd1q/79953eb0-d5ba-40d7-9573-e10ba95124e5-1489414415284564.pdf' ], tmpFilePath: '/tmp/tmp-448OUXMeYzqqGDc', execArgs: [ '\'/tmp/117213-448-1y9pd1q/79953eb0-d5ba-40d7-9573-e10ba95124e5-1489414415284564.pdf\'', 'cat', 'output', '/tmp/tmp-448OUXMeYzqqGDc' ], mode: 'BUFFER', keepTmpFile: false } ================= pdfMerge END Unhandled rejection Error: spawn EACCES at exports._errnoException (util.js:870:11) at ChildProcess.spawn (internal/child_process.js:298:11) at exports.spawn (child_process.js:362:9) at Object.exports.execFile (child_process.js:151:15) at PDFMerge.merge (/var/app/current/node_modules/pdf-merge/lib/PdfMerge.js:143:9) at PDFMerge.promise (/var/app/current/node_modules/pdf-merge/lib/PdfMerge.js:120:7) at /var/app/current/actions/stock/unstoring.js:718:16 at tryCatcher (/var/app/current/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/var/app/current/node_modules/bluebird/js/release/promise.js:512:31) at Promise._settlePromise (/var/app/current/node_modules/bluebird/js/release/promise.js:569:18) at Promise._settlePromise0 (/var/app/current/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/var/app/current/node_modules/bluebird/js/release/promise.js:693:18) at Promise._fulfill (/var/app/current/node_modules/bluebird/js/release/promise.js:638:18) at PromiseArray._resolve (/var/app/current/node_modules/bluebird/js/release/promise_array.js:126:19) at PromiseArray._promiseFulfilled (/var/app/current/node_modules/bluebird/js/release/promise_array.js:144:14) at Promise._settlePromise (/var/app/current/node_modules/bluebird/js/release/promise.js:574:26) at Promise._settlePromise0 (/var/app/current/node_modules/bluebird/js/release/promise.js:614:10) at Promise._settlePromises (/var/app/current/node_modules/bluebird/js/release/promise.js:693:18) at Async._drainQueue (/var/app/current/node_modules/bluebird/js/release/async.js:133:16) at Async._drainQueues (/var/app/current/node_modules/bluebird/js/release/async.js:143:10) at Immediate.Async.drainQueues [as _onImmediate] (/var/app/current/node_modules/bluebird/js/release/async.js:17:14) at processImmediate [as _immediateCallback] (timers.js:383:17)

That source run correctly in windows.

I think that issue is about permission.

But I don't know how can I resolove this issue?

wubzz commented 7 years ago

@minyoungk This is not a library issue. Like you said this is permissions on the server preventing you from either reading the PDF files or writing the temporary PDF file. Your user on the server needs permission.