Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk的 upload_slice 函数的url参数传什么呢 #10

Open
Seifon opened this issue Feb 20, 2023 · 1 comment
Open

sdk的 upload_slice 函数的url参数传什么呢 #10

Seifon opened this issue Feb 20, 2023 · 1 comment

Comments

@Seifon
Copy link

Seifon commented Feb 20, 2023

sdk的 upload_slice 函数的url参数传什么呢?

我只传了网盘路径,却报错,请问完整URL是怎么样的呢

@PeterDing
Copy link
Owner

分片上传前要通报服务器,它返回上传分片的连接。

参考:

pcs_prepared_file = api.create_file(
filename,
dest_file_id,
encrypt_io_len,
part_number=part_number,
check_name_mode=check_name_mode,
)
reset_encrypt_io(encrypt_io)
for upload_url in pcs_prepared_file.upload_urls():
_wait_start()
logger.debug(
"`upload_file`: upload_slice: slice_completed: %s", slice_completed
)
size = min(slice_size, encrypt_io_len - slice_completed)
if size == 0:
break
data = encrypt_io.read(size) or b""
io = BytesIO(data)
logger.debug(
"`upload_file`: upload_slice: size should be %s == %s", size, len(data)
)
# Retry upload until success
retry(
-1,
except_callback=lambda err, fail_count: (
io.seek(0, 0),
logger.warning(
"`upload_file`: `upload_slice`: error: %s, fail_count: %s",
err,
fail_count,
exc_info=err,
),
_wait_start(),
),
)(api.upload_slice)(io, upload_url, callback=callback_for_slice)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants