Ejemplo n.º 1
0
 def cache_issue_attachments(upload_file, user):
     message = {"cache_key": "", "message": "上传文件超过10M"}
     try:
         if RedisService.validate_upload_file(upload_file, 10 * 1024 * 1024,
                                              None):
             cached_key = str(user.id) + "_" + str(time.time())
             RedisService.set_object(cached_key, upload_file, 1800)
             message["cache_key"] = cached_key
     except Exception as ex:
         SimpleLogger.exception(ex)
         message["message"] = str(ex)
     return message
Ejemplo n.º 2
0
def cached_file(request):
    message = "0,上传失败"
    try:
        upload_file = request.FILES['attachment[0]']
        if RedisService.validate_upload_file(upload_file, 10 * 1024 * 1024,
                                             None):
            cached_key = str(request.user.id) + "_" + str(time.time())
            RedisService.set_object(cached_key, upload_file, 1800)
            message = cached_key + ",null"
    except Exception as ex:
        SimpleLogger.exception(ex)
        message = "0," + str(ex)
    return HttpResponse(message)