小编Avi*_*Bar的帖子

React-Native:将图片网址转换为base64字符串

我正在构建一个react native应用程序,需要以base64字符串格式存储图像以便离线查看功能.

什么库/函数会给我最好的结果来将图像存储为base64字符串?假设我的网址是" http://www.example.com/image.png ".

另外,在将其存储为字符串之前,是否需要发出http请求才能获取它?我的逻辑是肯定的,但在本机反应中,您可以在<Image>组件上加载图像,而无需先从服务器请求它们.

什么是最好的选择,做反应本机?

javascript base64 image react-native

28
推荐指数
8
解决办法
4万
查看次数

Puppeteer 内存增加问题

我在 Amazon Linux EC2 实例和 Macbook Air (OSX) 上运行 Puppeteer 脚本。该脚本必须保持在一页上,并一遍又一遍地重复执行表单填写任务。

我遇到了将其作为守护进程运行的问题pm2,我可以看到该进程的内存消耗每隔一两分钟就会增加,直到堵塞服务器的内存。

为了克服这个问题,我使用了--max-memory-restartflag of pm2,它可以防止服务器崩溃,但节点进程平均每30分钟重新启动一次。

这是代表我正在运行的代码的示例:

// Require the puppeteer library
const puppeteer = require('puppeteer');

async function scrape() {
    // Create the browser
    const browser = await puppeteer.launch({
        headless: true,
        ignoreHTTPSErrors: true,
        args: [
            '--no-sandbox',
            '--disable-setuid-sandbox',
            '--disable-dev-shm-usage',
            '--disable-accelerated-2d-canvas',
            '--no-first-run',
            '--no-zygote',
            '--single-process',
            '--disable-gpu',
            '--ignore-certificate-errors'
        ]
    });

    // Wrap scraping/testing code in try
    try {
        await initialFlow(browser, null); // Page instance is null for the first time …
Run Code Online (Sandbox Code Playgroud)

memory-leaks node.js puppeteer

5
推荐指数
1
解决办法
2801
查看次数