上传七牛后,移除图片

FFIB 2 years ago
parent
commit
e9ab830e77
1 changed files with 7 additions and 0 deletions
  1. 7 0
      kodo/oauth_settings.py

+ 7 - 0
kodo/oauth_settings.py

@@ -1,6 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3 3
 import logging
4
+import os
4 5
 
5 6
 from django.conf import settings
6 7
 
@@ -261,6 +262,9 @@ def DJANGO_FILE_UPLOAD_CALLBACK_FUNC(request, file_path=None, file_url=None):
261 262
         upload_file_req(file, file_path, bucket='tamron')
262 263
         file_url = qiniu_file_url(file_path, bucket='tamron')
263 264
 
265
+        if os.path.exists(file_path):
266
+            os.remove(file_path)
267
+
264 268
         return {
265 269
             'width': width,
266 270
             'height': height,
@@ -273,6 +277,9 @@ def DJANGO_FILE_UPLOAD_CALLBACK_FUNC(request, file_path=None, file_url=None):
273 277
         upload_file_req(file, file_path, bucket='tamron')
274 278
         file_url = qiniu_file_url(file_path, bucket='tamron')
275 279
 
280
+        if os.path.exists(file_path):
281
+            os.remove(file_path)
282
+
276 283
         return {
277 284
             'file_url': file_url,
278 285
         }