需要在Google Cloud Console中授予相关权限。具体步骤如下:
打开Google Cloud Console并进入您的项目。
点击左侧导航栏中的“IAM和管理”,然后再点击“IAM”。
在“成员”列表中查找并选择appspot.gserviceaccount.com。
点击“编辑”。
向下滚动到“权限”部分。
选择“添加权限”。
在搜索框中输入“Storage”,找到“Storage Object Creator”权限。
勾选该权限并点击“保存”。
至此,appspot.gserviceaccount.com账户应该拥有storage.objects.create权限了。如果您仍然不能访问,则可能需要检查您的代码以确保您在规定的项目中进行访问。您可以使用以下Python代码将文件上传至Google Cloud Storage:
from google.cloud import storage
# Authenticate with Google Cloud using a service account
client = storage.Client.from_service_account_json('PATH_TO_SERVICE_ACCOUNT_JSON_FILE')
# Get the bucket where the file will be uploaded
bucket = client.get_bucket('BUCKET_NAME')
# Create a blob object and upload the file to the bucket
blob = bucket.blob('DESTINATION_FILE_NAME')
blob.upload_from_filename('SOURCE_FILE_NAME')