Skip to content
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

Merged
merged 4 commits into from
May 16, 2024

Conversation

sywhb
Copy link
Contributor

@sywhb sywhb commented May 15, 2024

No description provided.

Copy link

vercel bot commented May 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
omnivore-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 4:27am
omnivore-prod ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2024 4:27am

Comment on lines -247 to -263
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)
})
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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

@sywhb
Copy link
Contributor Author

sywhb commented May 16, 2024

I simplified the code a bit, hopefully 😄

@sywhb sywhb merged commit b6dba11 into main May 16, 2024
3 of 5 checks passed
@sywhb sywhb deleted the feature/readable-content-download branch May 16, 2024 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants