第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Firebase云功能存儲(chǔ)可先觸發(fā)第一個(gè)縮略圖URL,然后再觸發(fā)與第一個(gè)相同的縮略圖URL

Firebase云功能存儲(chǔ)可先觸發(fā)第一個(gè)縮略圖URL,然后再觸發(fā)與第一個(gè)相同的縮略圖URL

千萬里不及你 2021-04-12 13:14:40
我正在嘗試將圖像上傳到Firebase,然后生成2個(gè)縮略圖。我能夠做到這一點(diǎn)沒有問題。我目前的障礙是,當(dāng)我將URL寫入實(shí)時(shí)數(shù)據(jù)庫時(shí),我總是得到與初始上傳相同的URL。例如:第一次上傳時(shí),我上傳的圖像帶有該圖像的兩個(gè)適當(dāng)?shù)目s略圖第2次上傳我得到的上傳的圖像帶有前兩個(gè)縮略圖(第一個(gè)圖像)第三次上傳時(shí),我得到的上傳的圖片帶有第一個(gè)圖片的縮略圖... ...這將繼續(xù)復(fù)制第一個(gè)上傳的網(wǎng)址在我的存儲(chǔ)中,正在生成正確的縮略圖,但是URL始終是第一次上傳嗎?我不知道這是否是getSignedUrl()的問題,真的不知道這里發(fā)生了什么。這是我的云函數(shù): export const generateThumbs = functions.storage    .object()    .onFinalize(async object => {    const bucket = gcs.bucket(object.bucket); // The Storage object.    // console.log(object);    console.log(object.name);    const filePath = object.name; // File path in the bucket.    const fileName = filePath.split('/').pop();    const bucketDir = dirname(filePath);    const workingDir = join(tmpdir(), 'thumbs');    const tmpFilePath = join(workingDir, 'source.png');    if (fileName.includes('thumb@') || !object.contentType.includes('image')) {      console.log('exiting function');      return false;    }    // 1. ensure thumbnail dir exists    await fs.ensureDir(workingDir);    // 2. Download Sounrce fileName    await bucket.file(filePath).download({      destination: tmpFilePath    });    //3. resize the images and define an array of upload promises    const sizes = [64, 256];    const uploadPromises = sizes.map(async size => {      const thumbName = `thumb@${size}_${fileName}`;      const thumbPath = join(workingDir, thumbName);      //Resize source image      await sharp(tmpFilePath)      .resize(size, size)      .toFile(thumbPath);      //upload to gcs      return bucket.upload(thumbPath, {        destination: join(bucketDir, thumbName),        metadata: {         contentType: 'image/jpeg'       }      })
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)