Support Topics Documentation Slack YouTube Blog

Image Resize (PHP)

I’d like to generate resized image files (thumbnails).

I thought it could be a good idea to do so via custom event handler and invoke something like this:

However, currently I cannot figure out how to directly access the backendless file system from code.
Any advice from where to start at best?

Direct file system access is allowed only in JS(Node.js) scripts running in Backendless Hosting. Custom business logic code running in API Engine can work with files only via API.


Do you have some sample code in JS (shoppingCartService or similar invoking File Api)?


The API doc has some samples:
Saving a file from an array of bytes:
File download: there is no example there, but any approach for downloading a file from a URL will work. Here’s one:

Regards, Mark

Any chances to host a JS file to which a client (android/iOS) could upload an image file?

I Could then resize it and save it via File Api.

What would be your preferred way to accomplish this task?


Yes, you should be able to do it that way. To do this, deploy your node.js script to the web/scripts folder. It must follow the expressJS pattern of accepting a request and returning a response. Any dependent node modules should be deployed to the web/scripts/node_modules directory.

In your script, you would obtain the data sent by the client from the “request” object and then do your image conversion magic.


Has anyone done this? I would like to have a process running which will compress/resize the uploaded image files.

I tried do resize using java code but got error: Could not initialize class javax.imageio.ImageIO, inspite of import javax.imageio.ImageIO;

ImageIO does a lot of things which are not permitted by the sandbox environment where custom code runs. For example, this is only one of the security exceptions raised by things that class does: access denied (“java.lang.RuntimePermission” “loadLibrary.awt”)

So how to make image cropping in custom code using java?

@Mark: any updates?
@Aleks P: did you manage to solve it somehow?

Unfortunately no, at now i upload created by client thumb with original one

I’m thinking about doing the same for MVP so we can ship, but it’s necessary to do the resizing on the server as soon as possible.

How about using this instead:


I need the same for my App resizing and crop the image uploaded by the user. Any news in how to do it inside Node.js service?

Hello @Mario_Ghersi

Is it to continue on this topic? Rotate photo registration image - #7 by stanislaw.grin

Yes I’m still looking for the right answer and sample code.