Skip to content

Commit

Permalink
Fix multer (GoogleCloudPlatform#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ace Nassri authored Sep 28, 2016
1 parent 981a323 commit 252e635
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 45 deletions.
16 changes: 7 additions & 9 deletions 3-binary-data/lib/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,14 @@ function sendUploadToGCS (req, res, next) {
// [END process]

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory and re-name to avoid
// conflicting with existing objects. This makes it straightforward to upload
// to Cloud Storage.
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
// [START multer]
var multer = require('multer')({
inMemory: true,
fileSize: 5 * 1024 * 1024, // no larger than 5mb
rename: function (fieldname, filename) {
// generate a unique filename
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now();
var Multer = require('multer');
var multer = Multer({
storage: Multer.MemoryStorage,
limits: {
fileSize: 5 * 1024 * 1024 // no larger than 5mb
}
});
// [END multer]
Expand Down
16 changes: 7 additions & 9 deletions 4-auth/lib/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ function sendUploadToGCS (req, res, next) {
}

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory and re-name to avoid
// conflicting with existing objects. This makes it straightforward to upload
// to Cloud Storage.
var multer = require('multer')({
inMemory: true,
fileSize: 5 * 1024 * 1024, // no larger than 5mb
rename: function (fieldname, filename) {
// generate a unique filename
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now();
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
var Multer = require('multer');
var multer = Multer({
storage: Multer.MemoryStorage,
limits: {
fileSize: 5 * 1024 * 1024 // no larger than 5mb
}
});

Expand Down
16 changes: 7 additions & 9 deletions 5-logging/lib/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ function sendUploadToGCS (req, res, next) {
}

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory and re-name to avoid
// conflicting with existing objects. This makes it straightforward to upload
// to Cloud Storage.
var multer = require('multer')({
inMemory: true,
fileSize: 5 * 1024 * 1024, // no larger than 5mb
rename: function (fieldname, filename) {
// generate a unique filename
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now();
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
var Multer = require('multer');
var multer = Multer({
storage: Multer.MemoryStorage,
limits: {
fileSize: 5 * 1024 * 1024 // no larger than 5mb
}
});

Expand Down
16 changes: 7 additions & 9 deletions 6-pubsub/lib/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,13 @@ function sendUploadToGCS (req, res, next) {
}

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory and re-name to avoid
// conflicting with existing objects. This makes it straightforward to upload
// to Cloud Storage.
var multer = require('multer')({
inMemory: true,
fileSize: 5 * 1024 * 1024, // no larger than 5mb
rename: function (fieldname, filename) {
// generate a unique filename
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now();
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
var Multer = require('multer');
var multer = Multer({
storage: Multer.MemoryStorage,
limits: {
fileSize: 5 * 1024 * 1024 // no larger than 5mb
}
});

Expand Down
16 changes: 7 additions & 9 deletions 7-gce/lib/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ function sendUploadToGCS (req, res, next) {
}

// Multer handles parsing multipart/form-data requests.
// This instance is configured to store images in memory and re-name to avoid
// conflicting with existing objects. This makes it straightforward to upload
// to Cloud Storage.
var multer = require('multer')({
inMemory: true,
fileSize: 5 * 1024 * 1024, // no larger than 5mb
rename: function (fieldname, filename) {
// generate a unique filename
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now();
// This instance is configured to store images in memory.
// This makes it straightforward to upload to Cloud Storage.
var Multer = require('multer');
var multer = Multer({
storage: Multer.MemoryStorage,
limits: {
fileSize: 5 * 1024 * 1024 // no larger than 5mb
}
});

Expand Down

0 comments on commit 252e635

Please sign in to comment.