在nginx上运行时在python中保存文件时可能导致错误的原因?

时间:2016-06-18 01:00:52

标签: python django nginx

我有一个.py脚本,它将base64文件保存到png文件

# SAVE BASE64 STRING TO PNG IMAGE
timestr = time.strftime("%Y%m%d%H%M%S")
filename = "/user_score/"+self.user.username+timestr+".png"
saved_file = MEDIA_ROOT+"/"+filename
fh = open(saved_file, "wb")
fh.write(imgbase64.decode('base64'))
fh.close()

这是通过AJAX函数调用到这样的URL

http://example-domain.com/score/save_image/?img=iVBORw0KGgoAAAANSUhEUgAAA4QAAAJYCAYAAAA6xSjbAAAgAElEQVR4Xu3b0ZYUN7KGUfz%2BD92z2mMYzDRUZkkKhfLf59ZFSrFDXHyLM399fHx8fPN%2FBAgQIECAAAECBAgQIBAn8JcgjNu5gQkQIECAAAECBAgQIPC3gCD0EAgQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQKCMHTxxiZAgAABAgQIECBAgIAg9AYIECBAgAABAgQIECAQKiAIQxdvbAIECBAgQIAAAQIECAhCb4AAAQIECBAgQIAAAQKhAoIwdPHGJkCAAAECBAgQIECAgCD0BggQIECAAAECBAgQIBAqIAhDF29sAgQIECBAgAABAgQICEJvgAABAgQIECBAgAABAqECgjB08cYmQIAAAQIECBAgQICAIPQGCBAgQIAAAQIECBAgECogCEMXb2wCBAgQIECAAAECBAgIQm%2BAAAECBAgQIECAAAECoQ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ZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgkIAgbLcNVCBAgQIAAAQIECBAgUCkgCCu1nUWAAAECBAgQIECAAIFGAoKw0TJchQABAgQIECBAgAABApUCgrBS21kECBAgQIAAAQIECBBoJCAIGy3DVQgQIECAAAECBAgQIFApIAgrtZ1FgAABAgQIECBAgACBRgKCsNEyXIUAAQIECBAgQIAAAQKVAoKwUttZBAgQIECAAAECBAgQaCQgCBstw1UIECBAgAABAgQIECBQKSAIK7WdRYAAAQIECBAgQIAAgUYCgrDRMlyFAAECBAgQIECAAAEClQKCsFLbWQQIECBAgAABAgQIEGgk8B%2B6jaetVJ6%2FbAAAAABJRU5ErkJggg%3D%3D

当我在本地和生产环境中运行django runserver时,它运行正常。 然而,当使用NGINX进行生产时,它给了我502。 所以一切都指向NGINX。

这是NGINX conf文件,虽然我无法访问错误日志(另一个程序员进行了设置)

user www-data;
worker_processes 5;
pid /var/run/nginx.pid;

events {
        worker_connections 6000;
        multi_accept on;
        use epoll;
}

http { 

        ##
        # Basic Settings
        ##
        client_max_body_size 30M;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 300;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    #timeout
    #proxy_read_timeout 1200;
    uwsgi_read_timeout 1200;
    client_body_timeout 120;
    client_header_timeout 120;
    send_timeout 100;
    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    #client_max_body_size 8m;
    large_client_header_buffers 4 32k;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}

任何想法都赞赏。

1 个答案:

答案 0 :(得分:0)

这是通过ohrstrom的评论解决的,https://serverfault.com/questions/564464/nginx-request-line-too-large/564468#564468与此答案相关联: instructions

这些参数:

client_header_buffer_size 1k;
large_client_header_buffers 4 32k;

阻止通话。

除此之外,我在网上发送如此大量的数据是一个非常糟糕的主意。我最终使用了一个带有身体上的base64数据的POST,这解决了这个问题。