-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow downloading/uploading readable content #3960
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const writableStream = storage | ||
.bucket(bucketName) | ||
.file(fileName) | ||
.createWriteStream() | ||
|
||
// Convert the string content to a readable stream | ||
const readableStream = new stream.Readable() | ||
readableStream.push(content) | ||
readableStream.push(null) // Signal the end of the stream | ||
|
||
// Pipe the readable stream to the writable stream to upload the file content | ||
await new Promise((resolve, reject) => { | ||
readableStream | ||
.pipe(writableStream) | ||
.on('finish', resolve) | ||
.on('error', reject) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think streaming
is not needed here because we still load the whole content in the memory and push it to the readStream
at once so it should be the same effect as uploading the whole content at once
@@ -426,79 +326,63 @@ export interface ProcessYouTubeTranscriptJobData { | |||
export const processYouTubeTranscript = async ( | |||
jobData: ProcessYouTubeTranscriptJobData | |||
) => { | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the try catch
block otherwise the failed jobs would never be retried
I simplified the code a bit, hopefully 😄 |
No description provided.