Package com.pugh.sockso.web

Examples of com.pugh.sockso.web.UploadFile


        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) );
View Full Code Here


   
    private void checkUploadLooksOk() throws BadRequestException {

        final Request req = getRequest();
        final Locale locale = getLocale();
        final UploadFile file = req.getFile( "musicFile" );

        if ( file == null )
            throw new BadRequestException( locale.getString("www.error.noFileUploaded") );

        // check mime type to see if it looks ok
        final String contentType = file.getContentType();
        log.debug( "File content type: " + contentType );
        if ( !Files.isValidMimeType(contentType) )
            throw new BadRequestException( locale.getString("www.error.unsupportedAudioFormat") );
       
        // check required fields
View Full Code Here

TOP

Related Classes of com.pugh.sockso.web.UploadFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.