Skip to content

Commit 8ff49d8

Browse files
authoredJan 6, 2023
chore(functions/v2): Migrate uploadFile sample to gen2 (#2965)
1 parent 114d77a commit 8ff49d8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎functions/http/uploadFile/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ const path = require('path');
2525
const os = require('os');
2626
const fs = require('fs');
2727

28+
const functions = require('@google-cloud/functions-framework');
29+
2830
// Node.js doesn't have a built-in multipart/form-data parsing library.
2931
// Instead, we can use the 'busboy' library from NPM to parse these requests.
3032
const Busboy = require('busboy');
3133

32-
exports.uploadFile = (req, res) => {
34+
functions.http('uploadFile', (req, res) => {
3335
if (req.method !== 'POST') {
3436
// Return a "method not allowed" error
3537
return res.status(405).end();
@@ -94,5 +96,5 @@ exports.uploadFile = (req, res) => {
9496
});
9597

9698
busboy.end(req.rawBody);
97-
};
99+
});
98100
// [END functions_http_form_data]

‎functions/http/uploadFile/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"node": ">=12.0.0"
1313
},
1414
"dependencies": {
15+
"@google-cloud/functions-framework": "^3.1.3",
1516
"@google-cloud/storage": "^6.0.0",
1617
"busboy": "^1.0.0"
1718
}

0 commit comments

Comments
 (0)