File upload Django活塞文件上传

File upload Django活塞文件上传,file-upload,curl,django-piston,File Upload,Curl,Django Piston,我正在使用django活塞和curl将文件发布到数据库中的特定电话号码但我上传文件时遇到问题。 这是我使用curl的帖子回复: C:\curl>curl -F "phone_number=03219455375" -F "file=@C:/file.txt" http://localhost:8000/api/uploadfile.json Piston/0.2.2 (Django 1.2.4) crash report: Method signature does not match.

我正在使用django活塞和curl将文件发布到数据库中的特定电话号码但我上传文件时遇到问题。

这是我使用curl的帖子回复:

C:\curl>curl -F "phone_number=03219455375" -F "file=@C:/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'
请帮忙Ok发现这很有帮助