checkUploadLooksOk();
final Properties p = getProperties();
final Request req = getRequest();
final Locale locale = getLocale();
final UploadFile file = req.getFile( "musicFile" );
final String artist = req.getArgument( "artist" );
final String album = req.getArgument( "album" );
final String track = req.getArgument( "title" );
// if we get here everything looks good, so lets try and save the file
try {
// make sure we've a directory to put the track in
final Database db = getDatabase();
final File dir = new File( Utils.getUploadsPath(db,p) + "/"+artist+" - "+album );
if ( !dir.exists() )
if ( !dir.mkdir() )
throw new BadRequestException( locale.getString("www.error.cantCreateTrackFolder"), 500 );
// write the track to disk
final File tempFile = file.getTemporaryFile();
final File newFile = new File( getNewUploadFilename(dir,track,Utils.getExt(file.getFilename())) );
tempFile.renameTo( newFile );
// rescan the folder to add new track to collection
final int collectionId = Integer.parseInt( p.get(Constants.WWW_UPLOADS_COLLECTION_ID) );