HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux aritmodecarnaval.es 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/www/aritmodecarnaval/nextcloud/apps/files_pdfviewer/pdfjs-get.js
const path = require('path')
const unzipper = require('unzipper')
const request = require('request')
const progress = require('request-progress')
const cliProgress = require('cli-progress')
const npmPackage = require('./package.json')

// Fetching pdf.js build release
const PDFJSversion = npmPackage.dependencies['pdfjs-dist'].slice(1)
console.info('Fetching pdfjs', PDFJSversion)

// Init progress
const pdfjsProgress = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic)
pdfjsProgress.start(100, 0)

progress(request(`https://github.com/mozilla/pdf.js/releases/download/v${PDFJSversion}/pdfjs-${PDFJSversion}-dist.zip`), {
	throttle: 50,
	delay: 0,
})
	.on('progress', function(state) {
		pdfjsProgress.update(state.size.transferred / state.size.total * 100)
	})
	.on('end', function() {
		pdfjsProgress.update(100)
		pdfjsProgress.stop()
		console.info('Done! \n')
	})
	.on('error', function(err) {
		console.error(err)
		throw new Error('Unable to download pdfjs dist')
	})
	.pipe(unzipper.Extract({ path: path.resolve(__dirname, 'js', 'pdfjs') }))