Exemple #1
0
def downloadFile(req, download_key, file_key, download_session_key, filename):
    bitparcel_download = BitparcelDownload(download_key, file_key, download_session_key, filename)

    response = HttpResponse(bitparcel_download.getChunkyKeyObj(), mimetype='application/octet-stream')
    response['Content-Disposition'] = 'attachment; filename="%s"' % bitparcel_download.row.filename
    response['Content-Length'] = bitparcel_download.row.size

    return response
Exemple #2
0
def download(req, download_key, filename):
    row = BitparcelDownload.getRow(download_key)

    url_filename = row.filename.replace(' ', '-')
    if (not filename) or (filename != url_filename):
        return HttpResponseRedirect('/%s/%s' % (download_key, url_filename))

    if row.downloads >= 5:
        return render_to_response('too_many_downloads.html', locals())

    download_session_key = DownloadSession.create()

    file_url = '/files/%s/%s/%s/%s' % (download_key, row.file_key, download_session_key, row.filename)

    return render_to_response('download.html', locals())