Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Support file revisions

Đang mở
#161 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu tại pydrive2/files.py, ở GetContentFile, và đọc tài liệu tham chiếu Google Drive revisions API được liên kết, sau đó theo dõi cách các ID tệp và các yêu cầu tải xuống được bao bọc. Hoàn thành có nghĩa là package có thể tải xuống một revision tệp được chỉ định bằng id của nó mà vẫn giữ nguyên hành vi tải xuống hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

feature request

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

Ngôn ngữ chính
Python
Star
670
Fork
75
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của iterative/PyDrive2

Tất cả issue của iterative/PyDrive2

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.