How to use the multer.MemoryStorage function in multer

To help you get started, we’ve selected a few multer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleCloudPlatform / nodejs-getting-started / 3-binary-data / lib / images.js View on Github external
req.file.cloudStoragePublicUrl = getPublicUrl(gcsname);
      next();
    });
  });

  stream.end(req.file.buffer);
}
// [END process]

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
// [START multer]
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 5 * 1024 * 1024, // no larger than 5mb
  },
});
// [END multer]

module.exports = {
  getPublicUrl,
  sendUploadToGCS,
  multer,
};
github GoogleCloudPlatform / training-data-analyst / courses / developingapps / v1.2 / nodejs / cloudstorage / start / server / gcp / cloudstorage.js View on Github external
// TODO: End the stream to upload the file's data



  // END TODO
}
// [END sendUploadToGCS]

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
// [START multer]
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 40 * 1024 * 1024 // no larger than 40mb
  }
});
// [END multer]

module.exports = {
  sendUploadToGCS,
  multer
};
github GoogleCloudPlatform / nodejs-getting-started / 6-pubsub / lib / images.js View on Github external
req.file.cloudStorageObject = gcsname;
    file.makePublic().then(() => {
      req.file.cloudStoragePublicUrl = getPublicUrl(gcsname);
      next();
    });
  });

  stream.end(req.file.buffer);
}

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 5 * 1024 * 1024, // no larger than 5mb
  },
});

module.exports = {
  downloadAndUploadImage,
  getPublicUrl,
  sendUploadToGCS,
  multer,
};
github GoogleCloudPlatform / nodejs-getting-started / optional-container-engine / lib / images.js View on Github external
stream.on('finish', () => {
    req.file.cloudStorageObject = gcsname;
    req.file.cloudStoragePublicUrl = getPublicUrl(gcsname);
    next();
  });

  stream.end(req.file.buffer);
}

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 5 * 1024 * 1024 // no larger than 5mb
  }
});

module.exports = {
  downloadAndUploadImage,
  getPublicUrl,
  sendUploadToGCS,
  multer
};
github GoogleCloudPlatform / training-data-analyst / courses / developingapps / nodejs / containerengine / start / frontend / gcp / cloudstorage.js View on Github external
req.file.cloudStoragePublicUrl = `https://storage.googleapis.com/${GCLOUD_BUCKET}/${oname}`;
      next();
    });
  });

  stream.end(req.file.buffer);
}
// [END process]

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
// [START multer]
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 40 * 1024 * 1024 // no larger than 40mb
  },
});
// [END multer]

module.exports = {
  sendUploadToGCS,
  multer,
};
github GoogleCloudPlatform / training-data-analyst / courses / developingapps / nodejs / cloudfunctions / bonus / server / gcp / cloudstorage.js View on Github external
req.file.cloudStoragePublicUrl = `https://storage.googleapis.com/${GCLOUD_BUCKET}/${oname}`;
      next();
    });
  });

  stream.end(req.file.buffer);
}
// [END process]

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
// [START multer]
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 40 * 1024 * 1024 // no larger than 40mb
  }
});
// [END multer]

module.exports = {
  sendUploadToGCS,
  multer
};
github GoogleCloudPlatform / nodejs-getting-started / 7-gce / lib / images.js View on Github external
req.file.cloudStorageObject = gcsname;
    file.makePublic().then(() => {
      req.file.cloudStoragePublicUrl = getPublicUrl(gcsname);
      next();
    });
  });

  stream.end(req.file.buffer);
}

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 5 * 1024 * 1024, // no larger than 5mb
  },
});

module.exports = {
  downloadAndUploadImage,
  getPublicUrl,
  sendUploadToGCS,
  multer,
};
github tamatamvan / tamvan-gcloud-storage-uploader-api / helpers / images.js View on Github external
})

  stream.on('finish', () => {
    req.file.cloudStorageObject = gcsname
    file.makePublic().then(() => {
      req.file.cloudStoragePublicUrl = getPublicUrl(gcsname)
      next()
    })
  })

  stream.end(req.file.buffer)
}

const Multer = require('multer'),
      multer = Multer({
        storage: Multer.MemoryStorage,
        limits: {
          fileSize: 5 * 1024 * 1024
        }
        // dest: '../images'
      })

module.exports = {
  getPublicUrl,
  sendUploadToGCS,
  multer
}
github GoogleCloudPlatform / training-data-analyst / courses / developingapps / v1.2 / nodejs / cloudstorage / end / server / gcp / cloudstorage.js View on Github external
// TODO: End the stream to upload the file's data

  stream.end(req.file.buffer);

  // END TODO
}

// [END sendUploadToGCS]

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
// [START multer]
const Multer = require('multer');
const multer = Multer({
  storage: Multer.MemoryStorage,
  limits: {
    fileSize: 40 * 1024 * 1024 // no larger than 40mb
  }
});
// [END multer]

module.exports = {
  sendUploadToGCS,
  multer
};

multer

Middleware for handling `multipart/form-data`.

MIT
Latest version published 2 years ago

Package Health Score

76 / 100
Full package analysis