Skip to content

Commit cf748c8

Browse files
authored
Firebase Ml Fix upload file naming (#392)
* Fix File Naming
1 parent 8770448 commit cf748c8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

firebase_admin/_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
16: exceptions.UNAUTHENTICATED,
7979
}
8080

81+
8182
def _get_initialized_app(app):
8283
if app is None:
8384
return firebase_admin.get_app()

firebase_admin/ml.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import datetime
2323
import re
2424
import time
25+
import os
2526
import requests
2627
import six
2728

@@ -440,8 +441,10 @@ def _parse_gcs_tflite_uri(uri):
440441
def upload(bucket_name, model_file_name, app):
441442
"""Upload a model file to the specified Storage bucket."""
442443
_CloudStorageClient._assert_gcs_enabled()
444+
445+
file_name = os.path.basename(model_file_name)
443446
bucket = storage.bucket(bucket_name, app=app)
444-
blob_name = _CloudStorageClient.BLOB_NAME.format(model_file_name)
447+
blob_name = _CloudStorageClient.BLOB_NAME.format(file_name)
445448
blob = bucket.blob(blob_name)
446449
blob.upload_from_filename(model_file_name)
447450
return _CloudStorageClient.GCS_URI.format(bucket.name, blob_name)

0 commit comments

Comments
 (0)