File tree 2 files changed +5
-2
lines changed
functions/http/uploadFile
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,13 @@ const path = require('path');
25
25
const os = require ( 'os' ) ;
26
26
const fs = require ( 'fs' ) ;
27
27
28
+ const functions = require ( '@google-cloud/functions-framework' ) ;
29
+
28
30
// Node.js doesn't have a built-in multipart/form-data parsing library.
29
31
// Instead, we can use the 'busboy' library from NPM to parse these requests.
30
32
const Busboy = require ( 'busboy' ) ;
31
33
32
- exports . uploadFile = ( req , res ) => {
34
+ functions . http ( ' uploadFile' , ( req , res ) => {
33
35
if ( req . method !== 'POST' ) {
34
36
// Return a "method not allowed" error
35
37
return res . status ( 405 ) . end ( ) ;
@@ -94,5 +96,5 @@ exports.uploadFile = (req, res) => {
94
96
} ) ;
95
97
96
98
busboy . end ( req . rawBody ) ;
97
- } ;
99
+ } ) ;
98
100
// [END functions_http_form_data]
Original file line number Diff line number Diff line change 12
12
"node" : " >=12.0.0"
13
13
},
14
14
"dependencies" : {
15
+ "@google-cloud/functions-framework" : " ^3.1.3" ,
15
16
"@google-cloud/storage" : " ^6.0.0" ,
16
17
"busboy" : " ^1.0.0"
17
18
}
You can’t perform that action at this time.
0 commit comments