将blob上传到appstore:查询参数到GET上传URL

时间:2014-02-21 05:25:35

标签: python django google-app-engine django-rest-framework blobstore

我正在使用App Engine for Python : Uploading a BLOB中的BLOB上传示例 唯一的区别是,因为我已经使用了Django REST框架,所以我决定使用它来代替webapp2来实现示例代码中的 MainHandler 类(&我没有使用表单)

class PdfUploadUrl(APIView):

    def get(self, request, *args, **kwargs):
        ##
        # Fetch the URL to which we upload the PDF
        ##
        log.debug('PdfUploadUrl: request.GET = %s:%s', type(request.GET), request.GET)
        upload_url = blobstore.create_upload_url('/pdfservice/upload')
        log.debug('PdfUploadUrl: upload_url = %s : %s', type(upload_url), upload_url)
        return Response(dict(upload_url=str(upload_url)))

当我这样从cURL打电话时

curl -i -G http://<my_app>.appspot.com/pdf/uploadurl

回应是

{"upload_url": "http://<my-app>.appspot.com/_ah/upload/AMmfu6au0EGRyH1ywfoJbR1XrLBM7V0JOAdVXwluktrBopvSBqh4DB1XIq6bzyvR9gpIfjfKAPREaWqCvkIb-i6MUQDf3eKMSdUhbS6punL1gn5dqUZckJIEU3_e78KxgRXDaH71D423/ALBNUaYAAAAAUwbj7SpdDkib8f2H8JQ6hlYA8-cTheTy/"}

现在,当我将请求更改为

curl -i -G http://<my-app>.appspot.com/pdf/uploadurl?xyz=bc

然后,响应是

{"upload_url": "http://<my-app>.appspot.com/_ah/upload/?xyz=bc/AMmfu6b4YEpDMuiFI494dY39yCCAehiAykQ2hy8fWEo1GS7kuQ6BKG9zR8TJhfDzlWbH6Fvc9TZWNBGTca7PY3DxY8f8-KKiKzIbS2k09CeMXBGVhfJE_EgGH0l_P3pL1ndVmL-6lGOF/ALBNUaYAAAAAUwbjrZJHTdW6rGDJZxLCuwbq46bw3Bk7/"}

实际上是一个无法使用的网址。查询参数是如何搞乱调用

的呢?
     blobstore.create_upload_url()

0 个答案:

没有答案