I am creating an online music streaming site, but I am not sure where to store the data: in a database, or in a web server, or anything else. I tried to write the data in a database, but the BLOB datatype can store only a limited size of audio files.
I tried to increase the max_allowed_packet
size but still I have the same error.

- 7,259
- 10
- 50
- 71

- 11
- 1
- 7
3 Answers
Actually you can store your music files in mysql by using the Datatype LONGBLOB it can store the maximum size of a file upto 4294967295.
But you should consider looking at this questions before.
What is the maximum length of data I can put in a BLOB column in MySQL?
-
but in mysql i have only one datatype "BLOB" to store such files. – user5277872 Sep 08 '15 at 05:05
-
do you have any other option i cannot store in database using BLOB – user5277872 Sep 08 '15 at 05:25
-
just store the file in directory and store the location in your database.. and this is a good practice also. – smali Sep 08 '15 at 05:35
You can store your audio file in Aws S3 bucket. Storing media files in mysql is not a good practice as most of the db memory will be occupied by media files. More information on how to stream audio from S3 is present here Streaming MP3s from Amazon S3
Another option would be to store your media file in filesystem and have the location saved in mysql. In this case you would write you own streaming logic to read and stream the file.
-
-
it is up to you to evaluate your options. If you are looking to stream audio, you can easily use AWS S3. The answer to this question has all the info you need for that http://stackoverflow.com/questions/689723/streaming-mp3s-from-amazon-s3 – Amm Sokun Sep 08 '15 at 08:35
-
I am totally confused. Can you please help me how to do this. "I am making an online music streaming site as a project in java using netbeans and mysql as a sever, but the only thing that i cannot do is upload & download my audio files". I am a beginner i have no idea how to do this all. Please please help me out. – user5277872 Sep 08 '15 at 09:59
Store it in a folder. As it is an unstructured data to its not feasible to store it in a database.
refer this link as it contains all the details how to upload and store it in a folder using jsp and servlet.
http://www.codeproject.com/Questions/1029210/How-to-upload-files-directly-in-a-folder-inn-java?arn=0

- 11
- 1
- 7