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)?
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:
java.security.AccessControlException: 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:
Java Advanced Imaging (JAI) is a Java platform extension API which allows developers to create their own image manipulation routines.
JAI is provided as a free download directly from Oracle Corporation for the Windows, Solaris, and Linux platforms. Apple Inc. provides a OS X version of the API from their website for Mac OS X v10.3. JAI ships with Mac OS X v10.4 and later.
While the API is provided in Java, platform-specific implementations can either use the pure Java implementation or provide ...
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?
Yes I’m still looking for the right answer and sample code.