使用谷歌api 从谷歌drive A文件夹拷贝 googlesheet 到B文件夹 文件大于6MB 报错 HttpError 500
SCOPES = [
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
"https://www.googleapis.com/auth/drive.appdata",
"https://www.googleapis.com/auth/drive.photos.readonly"
]
creds = None
token_json = os.path.dirname(__file__) + '/token.json'
client_secrets_json = os.path.dirname(__file__) + '/client_secrets.json'
if os.path.exists(token_json):
creds = Credentials.from_authorized_user_file(token_json, SCOPES)
print('creds', creds)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
while True:
try:
creds.refresh(Request())
break
except ssl.SSLEOFError:
time.sleep(2)
else:
flow = InstalledAppFlow.from_client_secrets_file(client_secrets_json, SCOPES)
creds = flow.run_local_server(port=0)
with open(token_json, 'w') as token:
token.write(creds.to_json())
socket.setdefaulttimeout(600)
service = build('drive', 'v3', credentials=creds)
service.files().copy(fileId=copy_file_key,
body={"name": copy_to_name,
"parents": [to_file_id],
"stream": True
}).execute()
googleapiclient.errors.HttpError:
尝试 socket.setdefaulttimeout(600) 这个不太行
也尝试缩小拷贝google sheet 文件,缩小后脚本可以使用
谁能帮帮我
把一个比较大的Google sheet 从Googledrive A 文件目录下,拷贝到Googledrive B文件目录下
您可以采取几个步骤来尝试解决您遇到的 HTTP 500 错误问题: