views:

310

answers:

4

I've got a project which requires a fairly complicated process and I want to make sure I know the best way to do this. I'm using ASP.net C# with Adobe Flex 3. The app server is Mosso (cloud server) and the file storage server is Amazon S3. The existing site can be viewed at NoiseTrade.com

I need to do this:

  • Allow users to upload MP3 files to an album "widget"
  • After the user has uploaded their album/widget, I need to automatically zip the mp3 (for other users to download) and upload the zip along with the mp3 tracks to Amazon S3

I actually have this working already (using client side processing in Flex) but this no longer works because of Adobe's flash 10 "security" update. So now I need to implement this server-side.

The way I am thinking of doing this is:

  • Store the mp3 in a temporary folder on the app server
  • When the artist "publishes" create a zip of the files in that folder using a c# library
  • Start the amazon S3 upload process (zip and mp3s) and email the user when it is finished (as well as deleting the temporary folder)

The major problem I see with this approach is that if a user deletes or adds a track later on I'll have to update the zip file but the temporary files will not longer exist.

I'm at a loss at the best way to do this and would appreciate any advice you might have.

Thanks!

A: 

MP3's are compressed. Why bother zipping them?

StingyJack
because you can group multiple files together this way, though in effect you're only getting the same functionality you would from the much-simpler .tar format.
Joel Coehoorn
yep, zipping to provide the artist's fans with a simple one-click download rather than track-by-track.
Mark
Oh... I read 'I need to automatically zip the mp3', so I thought we are talking bout single files.
StingyJack
A: 

I would say it is not necessary to zip a compressed file format, you are only gong to get a five percent reduction in filesize, give or take a little. Mp3's dont really zip up by their nature the have compressed most of the possible data already.

Karl
+1  A: 

The bit about updating the zip but not having the temporary files if the user adds or removes a track leads me to suspect that you want to build zips containing multiple tracks, possibly complete albums. If this is incorrect and you're just putting a single mp3 into each zip, then StingyJack is right and you'll probably end up making the file (slightly) larger rather than smaller by zipping it.

If my interpretation is correct, then you're in luck. Command-line zip tools frequently have flags which can be used to add files to or delete files from an existing zip archive. You have not stated which library or other method you're using to do the zipping, but I expect that it probably has this capability as well.

Dave Sherohman
Yes, the zip files will almost always contain more than one mp3 (most of the time they are full albums). The problem with modifying the existing zip file is that none of the files reside on the actual application server. They are all stored in Amazon S3 because of bandwidth costs.
Mark
Even so... How would you propose to modify a file (zipped or not) which resides on a different server? Unless the S3 server has a "modify zip file" API, then of course you'll have to download a copy of the old version, modify it, and upload the new version. No way around that, really.
Dave Sherohman
True, currently I am streaming all the tracks back into memory (using flash) and then zipping them and sending them back. I guess I would have to stream the tracks into server memory every time a new zip file was required. This won't be fun :/
Mark
A: 

DotNetZip can zip up files from C#/ASP.NET. I concur with the prior posters regarding compressibility of MP3s. DotNetZip will automatically skip compression on MP3, and just store the file, just for this reason. It still may be interesting to use a zip as a packaging/archive container, aside from the compression.

If you change the zip file later (user adds a track), you could grab the .zip file from S3, and just update it. DotNetZip can update zip files, too. But in this case you would have to pay for the transfer cost into and out of S3.

DotNetZip can do all of this with in-memory handling of the zips - though that may not be feasible for large archives with lots of MP3s and lots of concurrent users.

Cheeso