Skip to content

Commit

Permalink
chore: detailed logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed May 8, 2024
1 parent 4f45bef commit a9ab41d
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions config/image-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,20 @@ async function getGcsAuthToken() {
}

async function upload(stream, name, authToken) {
await request(
`https://storage.googleapis.com/upload/storage/v1/b/${GCS_BUCKET_NAME}/o?uploadType=media&name=${GCS_OBJECT_NAME_PREFIX}${name}`,
{
method: 'POST',
body: stream,
headers: { 'Content-Type': 'image/png', Authorization: `Bearer ${authToken}` },
throwOnError: true,
}
);
try {
const response = await request(
`https://storage.googleapis.com/upload/storage/v1/b/${GCS_BUCKET_NAME}/o?uploadType=media&name=${GCS_OBJECT_NAME_PREFIX}${name}`,
{
method: 'POST',
body: stream,
headers: { 'Content-Type': 'image/png', Authorization: `Bearer ${authToken}` },
throwOnError: true,
}
);
logger.error(response);
} catch (error) {
logger.error(`Upload !!! ${error}`);
}
return `${CDN_BASE_PATH}${name}`;
}

Expand Down Expand Up @@ -116,10 +121,6 @@ fetch(
`${CONTRACT_PRINCIPAL}/${TOKEN_NUMBER}-thumb.png`,
authToken
);
// const results = await Promise.all([
// ]);
// The API will read these strings as CDN URLs.
// for (const result of results) console.log(result);
console.log(url1);
console.log(url2);
console.error(`uploads done`);
Expand Down

0 comments on commit a9ab41d

Please sign in to comment.