4
我正在使用django-piston和curl將文件發佈到我的數據庫中的特定電話號碼。 但我在上傳文件時遇到問題。Django-piston文件上傳
這是用我的帖子迴應捲曲:
C:\curl>curl -F "phone_number=03219455375" -F "[email protected]:/file.txt"
http://localhost:8000/api/uploadfile.json
Piston/0.2.2 (Django 1.2.4) crash report:
Method signature does not match.
Resource does not expect any parameters.
Exception was: 'InMemoryUploadedFile' object is not subscriptable
Handler.py:
if request.POST:
phone_number=request.POST['phone_number']
file_name=request.FILES['file']
if(phone_number == ""):
return rc.BAD_REQUEST
else:
upload2folder = os.path.join(UPLOAD_ROOT,phone_number)
if os.path.exists(upload2folder):
print "Heloo'"
open(os.path.join(upload2folder, file_name),
'wb').write(file_name.)
else:
os.mkdir(upload2folder)
#open(os.path.join(upload2folder, file_name),
'wb').write(file_name.file.read())
return rc.CREATED
else:
return rc.BAD_REQUEST'
請幫幫忙!