Download the contents of a specific Drive revision by ID
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start in pydrive2/files.py at GetContentFile and read the linked Google Drive revisions API reference, then trace how file IDs and download requests are wrapped. Done means the package can download a specified file revision by its id while preserving the existing download behavior.
Written by the indexing model from the issue text.
Description
Hello PyDrive2 team,
First, thank you for developing and maintaining this package, I find it very helpful.
Second, I wanted to propose a new feature, which I personally find very useful (e.g. I am planning to use it for creating a simplified configuration management tool):
possibility to download a particular file revision by its id.
I have a code snipped that worked for me (based on GetContentFile function), but It has many shortcuts and potential flaws, therefore, I don't think it is good idea to create a PR with this code. Unfortunately, I don't have much experience working with the GDrive API to fix it myself.
@LoadAuth
def _GetContentRevision(
file,
rev_id,
filename,
chunksize=DEFAULT_CHUNK_SIZE,
):
revisions = file.auth.service.revisions()
file_id = file.metadata.get("id") or file.get("id")
if not file_id:
raise ValueError('No ID')
def _download(fd, request):
downloader = MediaIoBaseDownload(
fd, file._WrapRequest(request), chunksize=chunksize
)
done = False
while done is False:
status, done = downloader.next_chunk()
with open(filename, mode="w+b") as fd:
rev = revisions.get(fileId=file_id, revisionId=rev_id)
revision_metadata = rev.execute()
rev.uri = revision_metadata["downloadUrl"]
_download(fd, rev)
Hope you will find this feature useful as well.
-- Nikita
- Dominant language
- Python
- Stars
- 671
- Forks
- 76
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 46
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from iterative/PyDrive2
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Test cleanups after the 2.0 fix PRsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
maintenance priority-p2 tests
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
iterative/PyDrive2#399 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
-
awaiting response priority-p1 triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
iterative/PyDrive2#412 · 1 comment ·
Maintainers usually reply within 1 day
All issues in iterative/PyDrive2
Similar issues
-
A JSON chat answer blocks the backend event loop for the whole RAG runPossibly taken @NopeCharon claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
The-OpenROAD-Project/ORAssistant#656 ·
Maintainers usually reply within 1 day
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days