Not able to override creation default route

Expected behavior

I wanted to override the default routes present so that I could store images in s3 bucket.

Actual behavior

Whenever I am trying to override the default route, always the default route is being called instead of the other one.

Failure Logs

It prints the image parsed data and shows the following error in admin panel :-

Ads creation failed: value too long for type character varying(255)


I have implement the overrided route in route/ads.js as said in the documentation.

Hi @Nikhilesh_Ram,

It seems like your input value is too long for the type of field you’re using on your Postgres DB, I suggest you switch your Postgres field to “text” instead?

Let me know if that helps

Yes but I want to store the image in amazon bucket instead of my postgresql database. So for that also do I have to change the datatype.

You can still do that, if you extend the route, you can upload your file on your S3 and then store the image URL in your DB, but your DB datatype should be greater (so basically a “text”).

The type “character varying(255)” sets the limit of characters explicitly to 255.

Which DB field is concerned by your error?

if you want to update your field type you can run this query:

ALTER TABLE table_name ALTER COLUMN column_name TYPE text;

The image field which is of STRING datatype is throwing the error. But I need to store the image by overriding the route.
This will reduce the amount of computations.


Hi @Nikhilesh_Ram,

As I understand your need, you need an image (coming from S3) to be present alongside other fields of a record.
I suggest the following:

  • Create a smart field for the image field: (doc here) (put this in fields section in forest/yourModel.js:)
      field: 'myImageField',
      type: 'File',
      get: (album) => {
        // code to get the image from record+s3
      set: (record, myimage) => {
        // code to send the image to S3
  • Follow this example to get/store an image from S3. The example is for a smart action but the server code is the same.
  • To send larger images, configure your server to allow it. This thread matches this.


I have implemented the smart action method, but I want to override the default route and do it to reduce the amount of computations again.

I don’t understand, which computations do you plan to reduce?
The solution above does not contain any useless computation.
If you mean about json-parsing the body, this will be done even with a route override.

Whatever, you will find here informations to override a route.

The solution of smart action firstly stores the ads data and then by clicking the smart action, I upload the image and then the image field in the db gets updated. Rather if I could override the default route then I could change the image field coming with the other data and store it in the db by just a create query.

I tried implementing the override default route by reading the documentation but forest is still taking the default route instead of the override one.

Ok, I think we misunderstood for one thing,

It is not needed to implement a smart action.
The example of smart action just contains code showing how to put/get an image for S3.

Creating a smart field really looks what you need to implement an image field stored on S3.


I want to store the image on s3 and then the link has to be stored in the database.
So for this purpose since the image field doesn’t have BLOB type neither is required.
The default route tries to store the image in the database which would definitely won’t be successful.
So the execution procedure needs to be like this :-

1. Image has to be stored on s3.
2. The s3 url has to be overwritten in the image coming from admin panel.
3. The insert query has to take place.

So for this I need to override the default route.
I hope this gives some clarity.


It’s clear, thank you.

To do this a route override is not needed. A smart field is recommended:

  • Define a smart field image for the image content (as described above, no blob in your db)
  • Define a field imageUrl on the model to store the URL
  • In the smart field setter, send the image to S3 and then update the imageUrl field (example here)

So the link will be stored in the database :ok_hand:

Let me know if that’ ok.

Got it thank you so much for the help.

@Sliman_Medini @Simon_BRAMI1

1 Like