Here is an extracted source.
============================================================================
def upload():
###############################################################
# BEGIN Import
###############################################################
if request.env.request_method == 'POST':
form_import_submit = True
post_vars = request.post_vars
file_csv_value = None
delimiter = ','
try:
file_csv = post_vars.file_csv
filename = file_csv.filename
bufsize = file_csv.bufsize
filename_size = bufsize
"""
http://code.google.com/appengine/docs/python/blobstore/blobreaderclass.html
"""
blob_key = file_csv.type_options['blob-key']
# Instantiate a BlobReader for a given Blobstore value.
blob_reader = blobstore.BlobReader(blob_key)
file_csv_value = blob_reader.read()
filename_size = len(file_csv_value)
except Exception, e:
logging.info('%s:Error uploading=e=%s' % (sub, e))
msg = 'Error uploading.'
result = 400
http_host = 'My.appspot.com'
network = 'TestNetwork'
back_url = 'http://' + http_host + '/' + 'import' + '?network=' +
network
upload_url = blobstore.create_upload_url(back_url)
*upload_url* = blobstore.create_upload_url(back_url)
============================================================================
return dict(
*upload_url*=*upload_url*,
)
upload.html:
<form action="{{=*upload_url*}}" method="POST"
enctype="multipart/form-data" data-ajax="false">
<fieldset>
<div class="fieldWrapper" data-role="fieldcontain">
<label for="file_csv">Upload CSV file:</label>
<input type="file" name="file_csv"
id="file_csv" value="" />
</div>
</fieldset>
<input type="submit" value="Upload" data-theme="e"
data-ajax="false">
</form>
============================================================================
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-appengine/-/T9dFYdwkmugJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.