drive_v3 files.create unable to get resumable session URI
Maintainer thường phản hồi trong vòng 1 ngày
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
- 35/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ệ
- nodejs, typescript
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu với định nghĩa drive_v3 files.create trong src/apis/drive/v3.ts, sau đó kiểm tra createAPIRequestAsync trong src/apirequest.ts được liên kết của nodejs-googleapis-common. So sánh việc xây dựng request với tài liệu Drive về resumable uploads; công việc được xem là hoàn tất khi files.create có thể lấy URI của resumable session thông qua uploadType được chỉ định mà không cần POST thủ công hoặc override rootUrl.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Feature
I think that would be nice to be able to get the resumable session URI by specifying the uploadType: 'resumable' parameters on the drive_v3 files.create method, instead of doing a POST request.
const params = {
uploadType: 'resumable'
};
const options = {};
const res = await drive.files.create(params, options);
const uri = res.headers.location;
Motivation
Initially I thought that was the case by reading the documentation on how to perform a resumable upload (link).
So I take a look at the code to understand how to do that but unfortunately it seems impossible.
To summarise the documentation to get a resumable URI we need to do a POST like so:
POST https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable
If we take a look at how the create method it's implemented we found out that we have this URI in to the mediaUrl attribute. (link)
If we take a look how the request it's constructed we found out that only when we have the media.body the correct url it's used. But then the uploadType it's changed in to something else. So the POST request can't be constructed as desired. (link)
Solution
In this case a first simple fix would be modify the createAPIRequestAsync of googleapis-common to add another if statement to enforce the right URI when we have an empty body and the uploadType is set to "resumable". Pretty much like so:
if (parameters.mediaUrl && media.body) {
options.url = parameters.mediaUrl;
if (resource) {
params.uploadType = 'multipart';
// more code
} else {
params.uploadType = 'media';
// more code
}
} else if (parameters.mediaUrl && params.uploadType === 'resumable') {
options.url = parameters.mediaUrl;
} else {
options.data = resource || undefined;
}
The current solution that I could find instead is to override the URI in the options like so:
const options = {
rootUrl: 'https://www.googleapis.com/upload'
};
Please let me know if i'm missing something or if I should proceed with a pull request on nodejs-googleapis-common repository.
- Ngôn ngữ chính
- TypeScript
- Star
- 12.3k
- Fork
- 2k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 21
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-api-nodejs-client
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 32/100
googleapis/google-api-nodejs-client#3932 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Discovery Engine] streamAnswer is typed as one AnswerQueryResponse, but REST returns frame arraysĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
googleapis/google-api-nodejs-client#3930 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
googleapis/google-api-nodejs-client#3927 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
size: l type: feature request
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
googleapis/google-api-nodejs-client#3926 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type: feature request
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
googleapis/google-api-nodejs-client#3903 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/google-api-nodejs-client
Issue tương tự
-
priority: P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
prime-radiant-inc/evener#3291 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accessibility bug revealjs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
quarto-dev/quarto-cli#14961 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
supabase/agent-skills#614 ·
-
Content
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
RunestoneInteractive/rs#1559 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày