在Vercel里直接运行pdf.js包
const pdfjsLib = require("pdfjs-dist/es5/build/pdf.js");
会报下面的错:
Unhandled rejection: Error: Setting up fake worker failed: "Cannot find module './pdf.worker.js'
netstat -tulpn | grep :80 |
const blur = 3; // 模糊半径 | |
const url = 'https://user-images.githubusercontent.com/5717882/100448394-2325e300-30ed-11eb-9d9f-f5c3042e9ff1.png'; // 图片 | |
const canvas = Canvas.createCanvas(width, height); | |
const ctx = canvas.getContext('2d'); | |
const image = await Canvas.loadImage(url); | |
ctx.drawImage(image, 0, 0); | |
const imageData = ctx.getImageData(0, 0, width, height); | |
ctx.clearRect(0, 0, width, height); | |
const { data } = imageData; |
function decideFontColor(background) { | |
const red = parseInt(background.substr(0, 2), 16); | |
const green = parseInt(background.substr(2, 2), 16); | |
const blue = parseInt(background.substr(4, 2), 16); | |
if ((red * 0.299 + green * 0.587 + blue * 0.114) > 186) { | |
return '#000000'; | |
} | |
return '#ffffff'; | |
}; |
import stream from 'stream'; | |
app.get('/', function (req, res) { | |
const buffer = Buffer.from('p8AuXbAKFihL9N1H4aYi7w==', 'base64'); | |
const bufferStream = new stream.PassThrough(); | |
bufferStream.end(buffer); | |
bufferStream.pipe(res); | |
}); |
在Vercel里直接运行pdf.js包
const pdfjsLib = require("pdfjs-dist/es5/build/pdf.js");
会报下面的错:
Unhandled rejection: Error: Setting up fake worker failed: "Cannot find module './pdf.worker.js'
const FormData = require('form-data'); | |
const axios = require('axios'); | |
const file = (await axios.get('https://test.com/test.jpg', { responseType: 'stream' })).data; | |
const formData = new FormData(); | |
formData.append('file', file); | |
const res = await axios.post( | |
'https://test.com/upload', | |
formData, | |
{ |
export $(grep -v '^#' .env | xargs) |
sudo -u www-data php occ config:app:set files max_chunk_size --value 1000000 |
git log --diff-filter=A --follow --format=%aD -1 -- FILENAME |
You don't travel to see different things, you travel to see things differently.