How does the Cloud Code REST API handle post Form request data

Using the Cloud Code REST API

How to handle request data for post Form

I want to upload PNG images and process them in Cloud Code to generate IPFS

it should be possible, you can try with a small image and use to see how to access that data

Tried to report an error:
"error":"Unexpected token - in JSON at position 0"
my code:

Moralis.Cloud.define("fileUploadBuyLand", async function (request) {
  const logger = Moralis.Cloud.getLogger();
  const fileName = request.params.fileName;
  const pngFile = request.params.pngFile;"fileName:" + fileName);

  const png_nftFile = new Moralis.File(fileName, pngFile);
  await png_nftFile.saveIPFS();

  const nftPath = png_nftFile.ipfs();
  console.log("png nftPath:" + nftPath);
  return "nftPath:"+nftPath;

did it make it to this line or it gives that error in a different place?

did you update your server to latest version?

I deleted some of the code,

Moralis.Cloud.define("fileUploadBuyLand", async function (request) {
  const logger = Moralis.Cloud.getLogger();"test info");
  const fileName = request.params.fileName;"fileName:" + fileName);

This line of code is not executed:"test info");
An error:
"error":"Unexpected token - in JSON at position 0"

Is it because the submission is a PNG file

Parsing JSON directly is an error

The current server version:0.0.308

Found that the API Doc has such an interface

But don’t know how to upload files?

The file has been successfully uploaded by referring to this tutorial:

java code:

            File pngFile = FileUtil.file(ResourceUtil.getResource("list-img.png"));
            String moralis_api_url = "";
            JSONArray array = JSONUtil.createArray();
            JSONObject obj = JSONUtil.createObj();
            obj.putOpt("path", "RCT_PNG/" + pngFile.getName());
            obj.putOpt("content", pngToBase64(pngFile));
            HttpResponse response =
                    .header("X-API-KEY","you api key")
                    .header("Content-Type", "application/json")
                    .header("accept", "application/json")
  "response:{}", response.body());

private static String pngToBase64(File file) {
        try {
            byte[] fileContent = Files.readAllBytes(file.toPath());
            String encodeToString = Base64.getEncoder().encodeToString(fileContent);
  "pngFile Base64:{}", encodeToString);
            return encodeToString;
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        return null;

I think that you should convert the file contents to base64 before uploading it, anyway, it looks like you made it work

“error”:“request entity too large”

you should upload only json files with this uploadFolder endpoint, it doesn’t work now with big file sizes