简体   繁体   English

当用户访问页面时,如何在 FireBase 上托管用户上传的 mp3 文件而不会很快耗尽带宽?

[英]How do you host user-uploaded mp3 files on FireBase without quickly running out of bandwith when users access page?

My website provides artists with an audio visualization of their uploaded mp3 files.我的网站为艺术家提供他们上传的 mp3 文件的音频可视化。 Firebase Storage isn't necessarily the issue, but rather a bandwidth. Firebase 存储不一定是问题,带宽才是问题。 Every time a fan accesses the website, the website downloads the mp3 from Firebase Storage in order to access the frequency data to visualize it.每次粉丝访问该网站时,该网站都会从 Firebase 存储中下载 mp3,以访问频率数据以将其可视化。 Given each mp3 is ~8MB, you could see how even having 200 fans accessing the website would go over the 1GB free quota, so having thousands of people viewing the website would become expensive and not scalable.鉴于每个 mp3 大约 8MB,您可以看到即使有 200 个粉丝访问该网站也会超过 1GB 免费配额 go,因此让数千人访问该网站将变得昂贵且不可扩展。 I've considered hosting on SoundCloud, but I wouldn't be able to download the mp3 data in that case, only stream. What do people commonly do in this situation, where they need to have larger files like mp3s downloaded to display to the user without quickly running out of bandwidth?我考虑过在 SoundCloud 上托管,但在那种情况下我无法下载 mp3 数据,只能下载 stream。人们在这种情况下通常会做什么,他们需要下载 mp3 等较大的文件才能显示到用户不会很快耗尽带宽?

Firebase 带宽

Firebase Storage isn't necessarily the issue, but rather the bandwidth. Firebase 存储不一定是问题,带宽才是问题。 Every time a fan accesses the website, the website downloads the mp3 from Firebase Storage in order to access the frequency data to visualize it.每次粉丝访问该网站时,该网站都会从 Firebase 存储中下载 mp3,以访问频率数据以将其可视化。

So most likely, that's why you're having that problem related to the bandwidth because you're downloading all audio files, each time a user opens the website.所以很可能,这就是为什么您会遇到与带宽相关的问题,因为每次用户打开网站时,您都会下载所有音频文件。 That's not how you should handle this kind of situation.这不是你应该如何处理这种情况。 Instead of downloading all audio files, you should only display the name of the files, and only download them on demand.您不应下载所有音频文件,而应仅显示文件名称,并且按需下载。 For example, you should store the name of the files and corresponding URLs from Cloud Storage, either in Cloud Firestore or in the Realtime Database , and as soon as the user clicks the download/play button, only then does start playing/downloading them.例如,您应该将 Cloud Storage 中的文件名和相应的 URL 存储在Cloud Firestore实时数据库中,并且只要用户单击下载/播放按钮,就可以开始播放/下载它们。

Given each mp3 is ~8MB, you could see how even having 200 fans accessing the website would go over the 1GB free quota, so having thousands of people viewing the website would become expensive and not scalable.鉴于每个 mp3 大约 8MB,您可以看到即使有 200 个粉丝访问该网站也会超过 1GB 免费配额 go,因此让数千人访问该网站将变得昂贵且不可扩展。

The problem isn't about scalability, it's about costs.问题不在于可扩展性,而在于成本。 Cloud Storage for Firebase can easily scale to millions of files. Firebase 的云存储可以轻松扩展到数百万个文件。 Besides that, please also bear in mind that the free quota, it's used for testing puposes and not for real-world applications.除此之外,还请记住免费配额,它用于测试目的而不是用于实际应用程序。 For that scenario, you should consider upgrading to the Blaze Plan .对于这种情况,您应该考虑升级到Blaze Plan

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法通过 web 上的 Firebase 存储访问上传的文件 - Can't access uploaded files through Firebase storage on web 使用 React Native 将 mp3 上传到 Firebase 存储 Expo - Uploading an mp3 to Firebase Storage with React Native Expo email未验证时如何注销用户,Firebase Auth - How to sign out the user when the email is not verified, Firebase Auth 如何获取带有上传文件令牌的 url 到 firebase 存储? - How do I get url with token of uploaded file to firebase storage? 您如何将身份验证从 RTK 查询传递到 firebase 函数以访问实时数据库? - How do you pass authentication from an RTK Query to firebase functions to access realtime database? 您如何查看上传到 AWS 管理控制台的文件夹? - How do you view your folders uploaded to AWS Management Console? 你如何将model的用户和Firebase中的朋友收藏起来? - How would you model a collection of users and friends in Firebase? 如何限制用户下载上传到aws s3的文件 - How to restrict users from download files uploaded to aws s3 Firebase:云存储高带宽 - Firebase: cloud storage high bandwith 如何在 React Native 中向用户发送 Firebase 验证 email(以便用户可以验证他们的电子邮件)? - How do you send a Firebase verification email (so that a user can verify their email) to a user in React Native?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM