Hello, I want to add a button on the webpage I have embedded flexmonster in. It will save/upload the file to an AWS S3 bucket. I am trying to use the ‘save’ method (https://www.flexmonster.com/api/save/) to do that. Can anyone help me? An example that highlights this functionality would be great!
Also, I am pretty new to this so please pardon me if I ask something silly.
Thank you for your question.
In case your requirement is to upload the current configuration of the pivot as a JSON file to the AWS S3 bucket, the
save API call is a correct option.
Please note that AWS S3 bucket does not allow uploading the data directly from the client. Such limitation is due to security reasons. Therefore, initially, the report needs to be loaded to your own proxy server. Finally, this proxy server needs to pass the received data to the bucket.
In order to upload the report to the corresponding server, the following parameters of the
save method should be specified:
destinationparameter defines whether the file needs to be saved locally (“file”) or uploaded to the specified URL (“server”).
Please use the following code snippet for the reference:
In order to learn the way to receive such a file on the server-side, we suggest referring to the following forum thread. It contains a sample PHP code that demonstrates the way to receive the file.
Please let us know if it works for your case.
You are welcome to contact us in case any assistance is needed on this matter.
Thanks for the help. I now understand that I need to save the file on a proxy server first. I will follow the link and do the required steps. I wanted to ask you that once that is done, how do I use the ‘save’ API to POST the file on S3. Will filename:xyz, destination: server, and URL: (S3 bucket URL) be enough? Apologies again, I am a little new to this.
Thank you for giving us some time.
We want to explain that the proxy server is likely to require the authentication token to accept and process the received file.
Such a token should be passed to the server in request headers.
Flexmonster does not support sending request headers when using the
save API call. Instead, we suggest using the following approach:
Use the getReport API call to save the report as inline JSON.
Next, generate the corresponding POST request with request headers specified (for example, with capabilities of AJAX). Pass the received report in the body of such a request.
We also want to notice that the request needs to be sent to the URL of the proxy server, not the S3 Bucket URL.
We hope it helps.
Please contact us in case other questions arise.