Slow Uploads using Google Drive API with Python
@sqrrrl já está trabalhando nisso.
Desde 7/11/2024.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Expected Behavior
Automatically upload large files daily to Google Drive using Python, with upload speeds matching my internet connection.
Actual Behavior
The upload speed is stuck at around 20 Mbps, even when I use a faster network or adjust the chunk size in the script. I initially thought the issue was a limit within the Python code, but after testing the network speed in the same script, it showed speeds over 100 Mbps.
Here is my script:
file_name = os.path.basename(file_path)
file_size = os.path.getsize(file_path) / (1024 * 1024)
media = MediaFileUpload(file_path, mimetype='application/octet-stream', chunksize=256*1024 * 1024, resumable=True)
file_metadata = {
'name': file_name,
'parents': [folder_id] if folder_id else []
}
try:
request = service.files().create(media_body=media, body=file_metadata)
start_time = time.time()
response = request.execute()
print(f"Uploaded '{file_name}' successfully at {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
elapsed_time = time.time() - start_time
upload_speed = file_size / elapsed_time
print(f"Time used: {elapsed_time}\nUpload speed: {upload_speed:.2f} MB/s or {upload_speed*8:.2f} Mbps")
return True
except HttpError as error:
print(f"Failed to upload '{file_name}': {error}")
return False
I also tried changing the response part to:
response = None
while response is None:
status, response = request.next_chunk()
if status:
print("Uploaded %d%%." % int(status.progress() * 100))
but it showed almost the same results.
Specifications
- Python version: 3.12.7
- OS: Windows
- Linguagem predominante
- Python
- Estrelas
- 1.4k
- Forks
- 917
- Merge médio
- 3min
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de googleworkspace/python-samples
-
ايقاف البحث الأمنTalvez livre de novo @sqrrrl assumiu há 400 dias e não há nenhum pull request aberto. Aberta
googleworkspace/python-samples#2434 · 1 responsável ·
-
403 error from google after a few successful runs of my codeTalvez livre de novo @vinay-google assumiu há 912 dias e não há nenhum pull request aberto. Aberta
googleworkspace/python-samples#1424 · 1 responsável ·
-
How to see the progress of files which is getting uploadedTalvez livre de novo @vinay-google assumiu há 928 dias e não há nenhum pull request aberto. Aberta
googleworkspace/python-samples#1404 · 1 responsável ·
-
Phyton SamplesTalvez livre de novo @PierrickVoulet assumiu há 975 dias e não há nenhum pull request aberto. Aberta
googleworkspace/python-samples#1279 · 1 responsável ·
-
DefaultCredentialsError: Your default credentials were not found. To set up Application Default CredentialsTalvez livre de novo @sqrrrl assumiu há 1018 dias e não há nenhum pull request aberto. Aberta
googleworkspace/python-samples#1278 · 1 comentário · 1 responsável ·
Todas as issues de googleworkspace/python-samples
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
readthedocs/readthedocs-builder#73 ·
Mantenedores costumam responder em até 1 dia
-
area: ci bug good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
hffgzktbcc-blip/ounce-core#484 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
vllm-project/vllm-torchtpu#3395 ·
Mantenedores costumam responder em até 1 dia
-
Hermes plugin: MITM-domain discovery misses the model: block (provider/base_url nested under model:) — traffic blind-tunnels silently, zero compressionTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
ranxianglei/billion-context#7063 ·
Mantenedores costumam responder em até 1 dia