资源简介
iBarn-master.zip
代码片段和文件信息
# -*- coding: utf-8 -*-
#
# jQuery File Upload Plugin GAE Python Example 2.0
# https://github.com/blueimp/jQuery-File-Upload
#
# Copyright 2011 Sebastian Tschan
# https://blueimp.net
#
# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT
#
from __future__ import with_statement
from google.appengine.api import files images
from google.appengine.ext import blobstore deferred
from google.appengine.ext.webapp import blobstore_handlers
import json re urllib webapp2
WEBSITE = ‘http://blueimp.github.com/jQuery-File-Upload/‘
MIN_FILE_SIZE = 1 # bytes
MAX_FILE_SIZE = 5000000 # bytes
IMAGE_TYPES = re.compile(‘image/(gif|p?jpeg|(x-)?png)‘)
ACCEPT_FILE_TYPES = IMAGE_TYPES
THUMBNAIL_MODIFICATOR = ‘=s80‘ # max width / height
EXPIRATION_TIME = 300 # seconds
def cleanup(blob_keys):
blobstore.delete(blob_keys)
class UploadHandler(webapp2.RequestHandler):
def initialize(self request response):
super(UploadHandler self).initialize(request response)
self.response.headers[‘Access-Control-Allow-Origin‘] = ‘*‘
self.response.headers[
‘Access-Control-Allow-Methods‘
] = ‘OPTIONS HEAD GET POST PUT DELETE‘
def validate(self file):
if file[‘size‘] < MIN_FILE_SIZE:
file[‘error‘] = ‘File is too small‘
elif file[‘size‘] > MAX_FILE_SIZE:
file[‘error‘] = ‘File is too big‘
elif not ACCEPT_FILE_TYPES.match(file[‘type‘]):
file[‘error‘] = ‘Filetype not allowed‘
else:
return True
return False
def get_file_size(self file):
file.seek(0 2) # Seek to the end of the file
size = file.tell() # Get the position of EOF
file.seek(0) # Reset the file position to the beginning
return size
def write_blob(self data info):
blob = files.blobstore.create(
mime_type=info[‘type‘]
_blobinfo_uploaded_filename=info[‘name‘]
)
with files.open(blob ‘a‘) as f:
f.write(data)
files.finalize(blob)
return files.blobstore.get_blob_key(blob)
def handle_upload(self):
results = []
blob_keys = []
for name fieldStorage in self.request.POST.items():
if type(fieldStorage) is unicode:
continue
result = {}
result[‘name‘] = re.sub(r‘^.*\\‘ ‘‘
fieldStorage.filename)
result[‘type‘] = fieldStorage.type
result[‘size‘] = self.get_file_size(fieldStorage.file)
if self.validate(result):
blob_key = str(
self.write_blob(fieldStorage.value result)
)
blob_keys.append(blob_key)
result[‘delete_type‘] = ‘DELETE‘
result[‘delete_url‘] = self.request.host_url +\
‘/?key=‘ + urllib.quote(blob_key ‘‘)
if (IMAGE_TYPES.match(result[‘type‘])):
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-02-14 22:17 iBarn-master\
目录 0 2017-12-28 18:50 iBarn-master\action\
文件 5032 2017-12-28 18:50 iBarn-master\action\Collection.class.php
文件 37868 2017-12-28 18:50 iBarn-master\action\Core.class.php
文件 4610 2017-12-28 18:50 iBarn-master\action\Install.class.php
文件 12852 2017-12-28 18:50 iBarn-master\action\Share.class.php
文件 7697 2017-12-28 18:50 iBarn-master\action\User.class.php
目录 0 2017-12-28 18:50 iBarn-master\conf\
文件 171 2017-12-28 18:50 iBarn-master\conf\code.php
文件 2957 2017-12-28 18:50 iBarn-master\conf\config.php
文件 659 2017-12-28 18:50 iBarn-master\conf\filter.php
目录 0 2017-12-28 18:50 iBarn-master\conf\lang\
文件 5575 2017-12-28 18:50 iBarn-master\conf\lang\lang.php
文件 4062 2017-12-28 18:50 iBarn-master\conf\lang\tipLang.php
文件 3642 2017-12-28 18:50 iBarn-master\conf\mime.php
文件 148 2017-12-28 18:50 iBarn-master\conf\upload.php
目录 0 2017-12-28 18:50 iBarn-master\data\
文件 73 2017-12-28 18:50 iBarn-master\data\.gitignore
目录 0 2017-12-28 18:50 iBarn-master\html\
文件 7056 2017-12-28 18:50 iBarn-master\html\avatar.php
文件 12070 2017-12-28 18:50 iBarn-master\html\collection.php
文件 1526 2017-12-28 18:50 iBarn-master\html\error.php
文件 424 2017-12-28 18:50 iBarn-master\html\foot.php
文件 9438 2017-12-28 18:50 iBarn-master\html\head.php
文件 44169 2017-12-28 18:50 iBarn-master\html\index.php
文件 6311 2017-12-28 18:50 iBarn-master\html\install.php
文件 4808 2017-12-28 18:50 iBarn-master\html\login.php
文件 15853 2017-12-28 18:50 iBarn-master\html\myshare.php
文件 12678 2017-12-28 18:50 iBarn-master\html\offer.php
文件 11823 2017-12-28 18:50 iBarn-master\html\own.php
文件 11829 2017-12-28 18:50 iBarn-master\html\pay.php
............此处省略2309个文件信息
相关资源
- 全能地图器带注册机.rar
- hukewangjiexi.zip
- pdfiumDemo_src_exe.rar
- 微擎2.1.2-5gyun.zip
- 算法导论答案.rar
- AlgebraChapter0(PaoloAluffi).pdf
- CFA+2020+Level+II+-+SchweserNotes+Book+1.pdf
- ex14_SDRAM.rar
- xp330crackrom.zip
- 无线通信基础.zip
- efi-share.zip
- Houdini节点大全中文手册.rar
- 1109111213.zip
- BPA.rar
- 99彩时时彩整站带数据源码.rar
- 18239138BN090-体检系统.rar
- 一个人的电商:运营策略与实操手记
- 牛客校招面试题附答案与解析全集.
- 随书仿真模型.zip
- Cyuyancaoyanlong.zip
- 199806.txt
- resource.rar
- 微教育-多校版fm_jiaoyu3.12.16安装更新一
- come.rar
-
databa
sesystem(第五版).zip - 凸优化ConvexOptimization_Boyd中文版.pdf
- 奔跑吧ansible.pdf
- zw_wangkezhi5-10391405-XEP100演示代码.zip
- 老虎框架一键导入版5.99.17.zip
- Optiwave.OptiSystem.v7.0.With.Crack-NULL.part1
评论
共有 条评论