#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2017/12/28 13:56
# @Author : Aries
# @Site :
# @File : uploadFileQF.py
# @Software: PyCharm Community Edition
import os
from loggingutils.mylogger import logger as log
import time # 上传
def handle_uploaded_file(f, interface_name):
base_path = os.getcwd()
file_name = ''
try:
path = base_path + r'\kyoto\kyoTo\uploadfile'\
+ '\\' + time.strftime('%Y%m%d')
if not os.path.exists(path):
os.makedirs(path)
file_name = path + '\\' + time.strftime('%Y%m%d%H%M%S') + interface_name + 'TestData.txt'
log.info('file_name : ' + file_name)
destination = open(file_name, 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()
except Exception:
log.error('write file error')
return file_name # 下载(Django中返回对象用StreamingHttpResponse)
def download_file(filename, chunk_size=512):
with open(filename, 'rb') as f:
while True:
content = f.read(chunk_size)
if content:
yield content
else:
break
log.info('download operate success')
return content
												

最新文章

  1. React Native Android增加本地图片
  2. angular 嵌套实现树结构 ng-repeat ng-include
  3. ACM--South Pacific 2012
  4. Python 第九篇:队列Queue、生产者消费者模型、(IO/异步IP/Select/Poll/Epool)、Mysql操作
  5. k-d tree算法
  6. Java Web整合开发(80) -- EJB & WebService
  7. C#入门经典(第五章-2)字符串的处理
  8. python之smtplib发邮件
  9. 十二、 Spring Boot 静态资源处理
  10. PHP利用多进程处理任务
  11. BAT美团滴滴java面试大纲(带答案版)之三:多线程synchronized
  12. spring-session-data-redis解决session共享的问题
  13. [Android Pro] 完美解决 No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
  14. Linux 性能监控之CPU&内存&I/O监控Shell脚本1
  15. 使用POI读取/创建Execl(.xlsx)文件
  16. MySQL Desc指令相关
  17. 原创:微信小程序调用PHP后台接口,解析纯html文本
  18. 深入剖析Swift性能优化
  19. TCP的拥塞控制 (一)
  20. Highcharts 气泡图

热门文章

  1. 源码编译安装git
  2. Flume 中文入门手冊
  3. po vo
  4. docker使用问题总结
  5. Elastic_Terms 内容分类统计
  6. java:常用的两种设计模式(单例模式和工厂模式)
  7. 混合模式程序集是针对“v2.0.50727”版的运行时生成的
  8. sqlmap中tamper脚本绕过waf
  9. SpringBoot DataSource 配置说明
  10. 动态加载javascript增强版