Skip to content

Commit 252e635

Browse files
author
Ace Nassri
authored
1 parent 981a323 commit 252e635

File tree

5 files changed

+35
-45
lines changed

5 files changed

+35
-45
lines changed

3-binary-data/lib/images.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,14 @@ function sendUploadToGCS (req, res, next) {
6767
// [END process]
6868

6969
// Multer handles parsing multipart/form-data requests.
70-
// This instance is configured to store images in memory and re-name to avoid
71-
// conflicting with existing objects. This makes it straightforward to upload
72-
// to Cloud Storage.
70+
// This instance is configured to store images in memory.
71+
// This makes it straightforward to upload to Cloud Storage.
7372
// [START multer]
74-
var multer = require('multer')({
75-
inMemory: true,
76-
fileSize: 5 * 1024 * 1024, // no larger than 5mb
77-
rename: function (fieldname, filename) {
78-
// generate a unique filename
79-
return filename.replace(/\W+/g, '-').toLowerCase() + Date.now();
73+
var Multer = require('multer');
74+
var multer = Multer({
75+
storage: Multer.MemoryStorage,
76+
limits: {
77+
fileSize: 5 * 1024 * 1024 // no larger than 5mb
8078
}
8179
});
8280
// [END multer]

4-auth/lib/images.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@ function sendUploadToGCS (req, res, next) {
6262
}
6363

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

5-logging/lib/images.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@ function sendUploadToGCS (req, res, next) {
6262
}
6363

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

6-pubsub/lib/images.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,13 @@ function sendUploadToGCS (req, res, next) {
9090
}
9191

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

7-gce/lib/images.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,13 @@ function sendUploadToGCS (req, res, next) {
8888
}
8989

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

0 commit comments

Comments
 (0)