Smart Action failing to upload an image

Feature(s) impacted

Smart Action fails when attempting to upload an image.

Observed behavior

UI pops up saying Unexpected Error with Action. No console logs from local server or in browser.


If I upload a .txt file or .pdf, works fine.

Expected behavior

Error logs out somewhere or image is successfully uploaded.

Context

Running from a localhost server with the following code. Hopefully leading to uploading to an aws server

Collection code

collection("questionImage", {
  actions: [
    {
      name: "Coool Action",
      type: "global",
      fields: [
        {
          field: "imageTitle",
          isRequired: true,
          description: "The title of the image you want to upload",
          type: "String",
        },
        {
          field: "image",
          isRequired: true,
          description: "Image you need",
          type: "File",
        },
      ],
    },
  ],
  fields: [
    {
      field: "small_image_url",
      type: "String",
      get: (questionImage) => {
        return questionImage.imageUrl + "/small.png";
      },
    },
  ],
  segments: [],
});

Router code

router.post("/actions/coool-action", permissionMiddlewareCreator.smartAction(), (req, res) => {
  const attrs = req.body.data.attributes.values;
  const imageTitle = attrs["imageTitle"];
  const image = attrs["image"];

  res.send({ success: `Coool action has been done! ${imageTitle} ${image}` });
});
  • Project name: PlayED
  • Team name: Operations
  • Environment name: development
  • Agent type & version: Admin
  • Recent changes made on your end if any: none to my knowledge

Hey @Connor_Chaos, and welcome to our community :wave:

My first guess without the error would be maybe a file upload limit, but I may be wrong here

From the error, you should be getting an error on the HTTP call related to the smart action /actions/coool-action in your browser Network console. Could you share here both the request & response (Obfuscating sensitive data in the output) so we can check what is happening?

Thanks in advance :pray:

2 Likes

You would be correct!

Checking the Network console I got a [413-Payload To Large].

Looking through the forums led me to this fix (Maximum file size in a Smart Action field "File" - #2 by arnaud) which seemed to do the trick.

Thank ya for the pointers @jeffladiray !

1 Like