簡體   English   中英

需要使用 python 從雲存儲將文件從本地驅動器加載到谷歌雲平台

[英]need to load the file from local drive to Google cloud platfrom cloud storage using python

我正在嘗試使用下面編寫的 python 代碼將文件從本地驅動器復制到 gcp 雲存儲,但我收到以下文件未找到錯誤。

FileNotFoundError:[Errno 2] 沒有這樣的文件或目錄:'C:/Users//vithal//test.csv'

'''

from google.cloud import storage
import os
#pip install --upgrade google-cloud-storage.
def upload_to_bucket(landing_bucket_name):
  storage_client = storage.Client()
  project_id = 'abc'
  dataset_id = 'xyz'
  landing_bucket_name = '123'
  landing_blob_name = 'test_upload'
  local_path = "C://Users//test.csv"


#print(buckets = list(storage_client.list_buckets())

  bucket = storage_client.get_bucket(landing_bucket_name)  

  blob = bucket.blob(landing_blob_name)
  blob.upload_from_filename(local_path)


#returns a public url
  return blob.public_url

'''

你確定那里有文件嗎? 這是一個非常奇怪的存儲文件的地方!

我希望路徑更像c:/Users/vithaln/test.csv

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM