简体   繁体   English

需要使用 python 从云存储将文件从本地驱动器加载到谷歌云平台

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

i am trying to copy the file from local drive to gcp cloud storage using python code as written below but I am getting the below file not found error.我正在尝试使用下面编写的 python 代码将文件从本地驱动器复制到 gcp 云存储,但我收到以下文件未找到错误。

FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users//vithal//test.csv' 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

''' '''

Are you sure there is a file there?你确定那里有文件吗? It's a very strange place to store a file!这是一个非常奇怪的存储文件的地方!

I'd expect the path to be more like c:/Users/vithaln/test.csv我希望路径更像c:/Users/vithaln/test.csv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 python 将文件上传到 Google 云平台上的存储桶时出现问题 - Issue when uploading a file to a bucket on Google cloud platfrom using python 将数据从Google Cloud Storage上的本地文件加载到BigQuery表 - Load data from local file on Google Cloud Storage to BigQuery table 是否可以使用 App Engine 通过 Google Cloud Platform 上的本地路径从云存储桶对象加载文件? - Is it possible to load a file from a cloud storage bucket object by its local path on Google Cloud Platform using App Engine? 如何从谷歌云存储在 python 上加载 .pickle 文件 - How to load a .pickle file on python from google cloud storage 如何将文件从谷歌云存储加载到谷歌云功能 - How to load a file from google cloud storage to google cloud function 无法使用python将JSON文件从Google云存储加载到bigquery - Unable to load a JSON file from google cloud storage to bigquery using python 使用Python从Google云端存储下载多个文件 - Download multiple file from Google cloud storage using Python 使用Python从Google Cloud Storage下载大文件 - Download large file from Google Cloud Storage using Python 使用Python将文件从Google云端存储上传到Bigquery - Uploading a file from Google Cloud Storage to Bigquery using Python 使用Python的Google云存储 - Google Cloud Storage using Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM