예제 #1
0
파일: main.py 프로젝트: AloneRoad/Teardrop
def file(fid):
  filedata = get_file_data(fid)
  if not filedata:
    abort(404, 'File not found')
  response = app.make_response(filedata)
  response.headers['Content-Type'] = mimetype(filedata[:1024])
  response.headers['Content-Length'] = len(filedata)
  return response
예제 #2
0
파일: main.py 프로젝트: AloneRoad/Teardrop
def thumbnail(fid):
  key = 'z' + fid
  key = str(key)
  filedata = CACHE.get(key)
  if not filedata:
    filedata = get_file_data(fid)
    if not filedata:
      abort(404, 'File not found')
    filedata = zoom(filedata, 200, 200)
    CACHE.set(key, filedata)
  response = app.make_response(filedata)
  response.headers['Content-Type'] = mimetype(filedata[:1024])
  response.headers['Content-Length'] = len(filedata)
  return response
예제 #3
0
파일: img_utils.py 프로젝트: AloneRoad/jupo
def is_image(filedata):
  res = mimetype(filedata[:1024], mime=True)
  if res.startswith("image"):
    return True
  return False