Skip to content

New Cloud Modules for Images and Users

Parse is all about making life easier for developers. With that in mind, we've been hard at work adding new Cloud Modules to take care of some of the most common tasks users want to perform in Cloud Code. Today we're launching two new modules: the Parse Image Cloud Module, and the Parse User Session Module.

Parse Image Cloud Module

With the Parse Image Cloud Module, you can manipulate graphical images such as photos easily. For example, it's easy to create a Cloud Code Function to make a thumbnail of a photo.

var url = file.url();
Parse.Cloud.httpRequest({ url: url }).then(function(response) {
  // Create an Image from the data.
  var image = new Image();
  return image.setData(response.buffer);

}.then(function(image) {
  // Scale the image to a certain size.
  return image.scale({ width: 64, height: 64 });

}.then(function(image) {
  // Get the bytes of the new image.

}.then(function(buffer) {
  // Save the bytes to a new file.
  var file = new Parse.File("image.jpg", { base64: data.toString("base64"); });

This is great for beforeSave handlers. You can let Parse generate the images you need without doing the same image processing on every client. That helps you save bandwidth when it's time to download the thumbnail. It's also great for web apps, where you may not have native image processing libraries. For more information about the Parse Image Cloud Module, see our guide.

Parse User Session Module

Putting users at the center is key to making a great app experience. But for purely server-side apps, there was no good solution to keeping Parse Users logged in from page to page. Until now. We've added a great new Express middleware module to help you manage users logging in and out. Once you include the module, you just use the Parse.User methods you already know and love.

var parseExpressCookieSession = require('parse-express-cookie-session');

// In your middleware setup...
app.use(parseExpressCookieSession({ cookie: { maxAge: 3600000 } }));

// Making a "login" endpoint is SOOOOOOOO easy."/login", function(req, res) {
  Parse.User.logIn(req.body.username, req.body.password).then(function() {
    // Login succeeded, redirect to homepage.
    // parseExpressCookieSession will automatically set cookie.
  function(error) {
    // Login failed, redirect back to login form.
For details about the Parse User Session Module, see our guide.

What Cloud Module would you like us to add next? Leave a comment!