meblog / media /

Hudarsono Hu ccd4900 

Hudarsono 0f1eaae 
Hudarsono Hu ccd4900 
Hudarsono 0f1eaae 
Hudarsono cd4e2a9 

Hudarsono Hu ccd4900 

Hudarsono 0f1eaae 

Hudarsono Hu ccd4900 

Hudarsono cd4e2a9 

# Create your views here.
from django.http import HttpResponseRedirect, Http404, HttpResponse
from django.shortcuts import render_to_response
from google.appengine.ext import blobstore
from media import models
from fileform import FileForm
from utilities import blob_helper
import urllib
import logging

def upload(request):
    form = None
    if request.method =='POST':
        blob_info = blob_helper.get_uploads(request, field_name='media', populate_post=True)
        form = FileForm(request.POST)
        if form.is_valid() and len(blob_info) == 1:
            media_item = models.Media(title=form.cleaned_data['title'],
            return HttpResponseRedirect('/posts/')

        if len(media_blobs) == 0:
            request.session['upload_error'] = "Media file is required"

        form = FileForm(request.POST)

    if form is None: form = FileForm()
    upload_url = blobstore.create_upload_url('/media/upload/')
    return render_to_response('admin/upload.html', {'upload_url':upload_url,
													'upload_error': request.session.pop('upload_error', None),
													'form': form})

def download(request, key):
    blob_key = str(urllib.unquote(key))
    blob = blobstore.BlobInfo.get(blob_key)
    return blob_helper.send_blob(request, blob, save_as=True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.