Como configurar um ambiente de desenvolvimento de apps no Google Cloud: laboratório com desafio avaliações
343966 avaliações
Aakash P. · Revisado há 6 months
must update flow test, and index.js failed create for fail parsing bucket name, etc const functions = require('@google-cloud/functions-framework'); const { Storage } = require('@google-cloud/storage'); const { PubSub } = require('@google-cloud/pubsub'); const sharp = require('sharp'); functions.cloudEvent('memories-thumbnail-generator', async (cloudEvent) => { console.log('FULL EVENT:', JSON.stringify(cloudEvent)); const data = cloudEvent.data || {}; // fallback parsing const bucketName = data.bucket || data.data?.bucket; const fileName = data.name || data.data?.name; console.log(`Bucket: ${bucketName}`); console.log(`File: ${fileName}`); if (!bucketName || !fileName) { console.error('Missing bucket or filename'); return; } if (fileName.includes('64x64_thumbnail')) { console.log('Thumbnail already exists'); return; } const ext = fileName.split('.').pop().toLowerCase(); if (!['jpg', 'jpeg', 'png'].includes(ext)) { console.log('Unsupported file type'); return; } const storage = new Storage(); const bucket = storage.bucket(bucketName); const filenameWithoutExt = fileName.substring( 0, fileName.length - ext.length - 1 ); const newFilename = `${filenameWithoutExt}_64x64_thumbnail.${ext}`; try { const [buffer] = await bucket.file(fileName).download(); const resizedBuffer = await sharp(buffer) .resize(64, 64, { fit: 'inside', withoutEnlargement: true, }) .toFormat(ext) .toBuffer(); await bucket.file(newFilename).save(resizedBuffer, { metadata: { contentType: `image/${ext}`, }, }); console.log(`Created ${newFilename}`); const pubsub = new PubSub(); await pubsub .topic('topic-memories-423') .publishMessage({ data: Buffer.from(newFilename), }); console.log('Pub/Sub message published'); } catch (err) { console.error(err); } });
Randi S. · Revisado há 6 months
Ranjith E. · Revisado há 6 months
Takatoshi K. · Revisado há 6 months
MS.LOVELY S. · Revisado há 6 months
Shiva Shankar Prakash M. · Revisado há 6 months
Pallavi S. · Revisado há 6 months
Ngoc P. · Revisado há 6 months
good
Gopi T. · Revisado há 6 months
Bernal Esteban S. · Revisado há 6 months
Piotr K. · Revisado há 6 months
Ruddhi B. · Revisado há 6 months
I could not start the lab. I got the error: Unable to create your bucket at this time. Try again or contact your administrator.
Luis A. · Revisado há 6 months
Minyoung W. · Revisado há 6 months
Satisfeito
Carlos T. · Revisado há 6 months
Edgardo Alfredo M. · Revisado há 6 months
Ricardo Andres F. · Revisado há 6 months
Edgardo Alfredo M. · Revisado há 6 months
Maria de los Angeles H. · Revisado há 6 months
Luan C. · Revisado há 6 months
Jonathan S. · Revisado há 6 months
Fabiana C. · Revisado há 6 months
Criei bucket e a função, mas o progresso não avança
Pedro Lucas A. · Revisado há 6 months
Pedro Henrique S. · Revisado há 6 months
challenging
Stephan Christian F. · Revisado há 6 months
Não garantimos que as avaliações publicadas sejam de consumidores que compraram ou usaram os produtos. As avaliações não são verificadas pelo Google.