def upload_sftp(request): song_list = [] sketchy = False sftp_upload_dir = settings.AENCLAVE_SFTP_UPLOAD_DIR # Figure out available MP3's in SFTP upload DIR for root, dirs, files in os.walk(sftp_upload_dir): for filename in files: if processing.valid_song(filename): full_path = root + '/' + filename content = File(open(full_path, 'r')) song, audio = processing.process_song(full_path, content) song_list.append(song) if audio.info.sketchy: sketchy = True #remove the file from the sftp-upload directory os.unlink(full_path) return render_html_template('aenclave/upload_sftp.html', request, { 'song_list': song_list, 'sketchy_upload': sketchy }, context_instance=RequestContext(request))
def upload_sftp(request): song_list = [] sketchy = False sftp_upload_dir = settings.AENCLAVE_SFTP_UPLOAD_DIR # Figure out available MP3's in SFTP upload DIR for root, dirs, files in os.walk(sftp_upload_dir): for filename in files: if processing.valid_song(filename): full_path = root + '/' + filename content = File(open(full_path, 'r')) song, audio = processing.process_song(full_path, content) song_list.append(song) if audio.info.sketchy: sketchy = True #remove the file from the sftp-upload directory os.unlink(full_path) return render_html_template('aenclave/upload_sftp.html', request, {'song_list': song_list, 'sketchy_upload': sketchy}, context_instance=RequestContext(request))
def upload_http_fancy_receiver(request): logging.info("Got fancy receiver request.") audio = None # The key is generally 'Filedata' but this is just easier. for k, f in request.FILES.items(): audio = f # SWFUpload does not properly fill out the song's mimetype, so # just use the extension. if audio is None: logging.error("Did not find any file uploaded.") return html_error(request, 'No file was uploaded.', 'HTTP Upload') logging.info("Received upload of %s" % audio.name) if not processing.valid_song(audio.name): logging.error("Rejecting upload due to unsupported filetype") return html_error(request, 'This filetype is unsupported.', 'HTTP Upload') # Save the song into the database -- we'll fix the tags in a moment. song, audio = processing.process_song(audio.name, audio) return render_html_template('aenclave/songlist_song_row.html', request, {'song': song}, context_instance=RequestContext(request))
def upload_http_fancy_receiver(request): logging.info("Got fancy receiver request.") audio = None # The key is generally 'Filedata' but this is just easier. for k,f in request.FILES.items(): audio = f # SWFUpload does not properly fill out the song's mimetype, so # just use the extension. if audio is None: logging.error("Did not find any file uploaded.") return html_error(request, 'No file was uploaded.', 'HTTP Upload') logging.info("Received upload of %s" % audio.name) if not processing.valid_song(audio.name): logging.error("Rejecting upload due to unsupported filetype") return html_error(request, 'This filetype is unsupported.', 'HTTP Upload') # Save the song into the database -- we'll fix the tags in a moment. song, audio = processing.process_song(audio.name, audio) return render_html_template('aenclave/songlist_song_row.html', request, {'song': song}, context_instance=RequestContext(request))