Please let me know how to do this
SERVER_ONE: this is the application server
SERVER_TWO: this is the file storage server
The objective is to
>>> have the user select a file via a form (this is via a Web2py app running on SERVER_ONE)
>>> when user clicks the submit button, the file is posted to an API endpoint on SEVER_TWO
>>> the web2py app on SERVER_TWO then saves the file to disk
Here is my code for SERVER_ONE:
def file_upload():
form = FORM(
DIV(
INPUT(
_type = "file",
_name = "file",
requires = IS_LENGTH(MAX_IMAGE_UPLOAD_SIZE, MIN_IMAGE_UPLOAD_SIZE),
)
),
DIV(
INPUT(
_type = "submit",
_value = "UPLOAD IMAGE"
)
),
_method = "post",
_enctype="multipart/form-data",
)
if (form.process().accepted):
SERVER_TWO_APP_BASE_URL + "/default/get_file",
files={'file': form.vars.file.file.read()}
)
return dict(
form = form,
)
Here is my code for in default.py controller of SERVER_TWO:
import requests
def get_file():
try:
file = request.files['file']
file.save('', file.filename)
except Exception as e:
with open("_probe_20191013_001", "w") as f:
f.write(str(e))
with open("_probe_20191013_002", "w") as f:
f.write("\n\nthis is a test\n\n")
f.write(str(request))
return dict()
==============================================================
The file is not getting saved on SERVER_TWO
does anyone have any advice on how to accomplish that?