Звучит просто, но функция request.post(), похоже, не передает такой файл должным образом:
Код: Выделить всё
def post(self, request, *args, **kwargs):
data = request.data
print(data)
#
endpoint = OTHER_API_URL + "/endpoint"
r = requests.post(endpoint, files=data)
Код: Выделить всё
@app.route("/endpoint", methods=["POST"])
def endpoint():
if flask.request.method == "POST":
# I removed the many checks to simplify the code
file = flask.request.files['file']
path = os.path.join(UPLOAD_FOLDER, file.filename)
file.save(path)
print(file) #
print(os.path.getsize(path)) #0
return [{"response":"ok"}]
Код: Выделить всё
print(file) #
print(os.path.getsize(path)) #8541
Подробнее здесь: https://stackoverflow.com/questions/511 ... l-rest-api