Skip to content

Commit 5fc1011

Browse files
Ace Nassrileahecole
andauthored
chore(functions): remove unused signed url sample (GoogleCloudPlatform#4889)
* chore(functions): remove unused signed url sample * Fix lint Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
1 parent 4749aa8 commit 5fc1011

File tree

2 files changed

+0
-47
lines changed

2 files changed

+0
-47
lines changed

functions/http/main.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# [START functions_http_signed_url]
16-
from datetime import datetime, timedelta
17-
# [END functions_http_signed_url]
18-
1915
# [START functions_http_xml]
2016
import json
2117
# [END functions_http_xml]
@@ -25,11 +21,6 @@
2521
import tempfile
2622
# [END functions_http_form_data]
2723

28-
# [START functions_http_signed_url]
29-
from flask import abort
30-
from google.cloud import storage
31-
# [END functions_http_signed_url]
32-
3324
# [START functions_http_form_data]
3425
from werkzeug.utils import secure_filename
3526
# [END functions_http_form_data]
@@ -100,30 +91,6 @@ def parse_multipart(request):
10091
# [END functions_http_form_data]
10192

10293

103-
# [START functions_http_signed_url]
104-
storage_client = storage.Client()
105-
106-
107-
def get_signed_url(request):
108-
if request.method != 'POST':
109-
return abort(405)
110-
111-
request_json = request.get_json()
112-
113-
# Get a reference to the destination file in GCS
114-
bucket_name = request_json['bucket']
115-
file_name = request_json['filename']
116-
file = storage_client.bucket(bucket_name).blob(file_name)
117-
118-
# Create a temporary upload URL
119-
expires_at_ms = datetime.now() + timedelta(seconds=30)
120-
url = file.generate_signed_url(expires_at_ms,
121-
content_type=request_json['contentType'])
122-
123-
return url
124-
# [END functions_http_signed_url]
125-
126-
12794
# [START functions_http_cors]
12895
def cors_enabled_function(request):
12996
# For more information about CORS and CORS preflight requests, see

functions/http/main_test.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
1715
import flask
1816
import pytest
1917

@@ -49,18 +47,6 @@ def test_parse_multipart_files(app, capsys):
4947
assert out == 'Processed file: test.py\n'
5048

5149

52-
def test_get_signed_url(app, capsys):
53-
json = {
54-
'bucket': os.getenv('GOOGLE_CLOUD_PROJECT'),
55-
'filename': 'test.txt',
56-
'contentType': 'text/plain'
57-
}
58-
59-
with app.test_request_context(method='POST', json=json):
60-
url = main.get_signed_url(flask.request)
61-
assert 'https://storage.googleapis.com/' in url
62-
63-
6450
def test_cors_enabled_function_preflight(app):
6551
with app.test_request_context(method='OPTIONS'):
6652
res = main.cors_enabled_function(flask.request)

0 commit comments

Comments
 (0)