Compare commits
2 commits
24a455f138
...
215d36f20a
Author | SHA1 | Date | |
---|---|---|---|
215d36f20a | |||
b3a368973e |
1 changed files with 18 additions and 13 deletions
|
@ -27,22 +27,27 @@ export async function createThumbnail(upload: Upload) {
|
||||||
.replaceAll('+', '-')
|
.replaceAll('+', '-')
|
||||||
.replaceAll('/', '_');
|
.replaceAll('/', '_');
|
||||||
|
|
||||||
const response = await fetch(`${env.THUMBOR_ENDPOINT}/${SIGNATURE}/${options}/${url}`);
|
try {
|
||||||
const arrayBuffer = await response.arrayBuffer();
|
const response = await fetch(`${env.THUMBOR_ENDPOINT}/${SIGNATURE}/${options}/${url}`);
|
||||||
|
const arrayBuffer = await response.arrayBuffer();
|
||||||
|
|
||||||
const filePath = `thumbnails/${Date.now()}-${upload.id}.webp`;
|
const filePath = `thumbnails/${Date.now()}-${upload.id}.webp`;
|
||||||
|
|
||||||
const record = await prisma.thumbnail.create({
|
const record = await prisma.thumbnail.create({
|
||||||
data: {
|
data: {
|
||||||
uploadId: upload.id,
|
uploadId: upload.id,
|
||||||
fileName: filePath
|
fileName: filePath
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
await minio.putObject(BUCKET, filePath, Buffer.from(arrayBuffer), arrayBuffer.byteLength, {
|
await minio.putObject(BUCKET, filePath, Buffer.from(arrayBuffer), arrayBuffer.byteLength, {
|
||||||
'Content-Type': 'image/webp'
|
'Content-Type': 'image/webp'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return record;
|
||||||
|
} catch (_) {
|
||||||
|
console.log(_);
|
||||||
|
}
|
||||||
|
|
||||||
processing.delete(upload.id);
|
processing.delete(upload.id);
|
||||||
return record;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue