Office365-rest-python-client: 파일 λ‹€μš΄λ‘œλ“œ μ‹œ MissingSchema 였λ₯˜ μš”μ²­

에 λ§Œλ“  2020λ…„ 10μ›” 02일  Β·  4μ½”λ©˜νŠΈ  Β·  좜처: vgrem/Office365-REST-Python-Client

μ•ˆλ…•ν•˜μ„Έμš”!

μ΅œμ‹  2.2.1 λ²„μ „μ˜ Office365λ₯Ό μ‚¬μš©ν•˜μ—¬ SharePointμ—μ„œ νŒŒμΌμ„ λ‹€μš΄λ‘œλ“œν•˜λŠ” 데 λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€. νŒŒμΌμ„ λ‹€μš΄λ‘œλ“œν•˜λ €κ³  ν•˜λ©΄ μš”μ²­ λͺ¨λ“ˆμ—μ„œ "MissingSchema" 였λ₯˜κ°€ λ‚˜νƒ€λ‚©λ‹ˆλ‹€. 버전 2.1.5둜 λŒμ•„κ°€λ©΄ μ½”λ“œκ°€ μ œλŒ€λ‘œ μ‹€ν–‰λ©λ‹ˆλ‹€. λŒ€λ‹¨νžˆ κ°μ‚¬ν•˜λ©° 이 λͺ¨λ“ˆμ˜ 노고에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€. 맀우 μœ μš©ν•©λ‹ˆλ‹€!

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.file import File

def auth(username, password):
    ctx_auth = AuthenticationContext(url)
    if ctx_auth.acquire_token_for_user(username, password):
      ctx = ClientContext(url, ctx_auth)
      return ctx

ctx = auth(username, password)
response = File.open_binary(ctx, relative_url)

였λ₯˜:
MissingSchema: Invalid URL "<bound method ClientContext.service_root_url of <office365.sharepoint.client_context.ClientContext object at 0x7fb4e44c3d90>>web/getfilebyserverrelativeurl('MYRELATIVEURL')/\\$value": No schema supplied. Perhaps you meant http://<bound method ClientContext.service_root_url of <office365.sharepoint.client_context.ClientContext object at 0x7fb4e44c3d90>>web/getfilebyserverrelativeurl('MYRELATIVEURL')/\$value?

MacOSλ₯Ό μ‚¬μš©ν•˜μ—¬,
μ˜€ν”ΌμŠ€365 2.2.1,
파이썬 3.8.3,
μš”μ²­ 2.2.4

bug question

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

2.2.1 λ²„μ „μ—λŠ” git의 μ΅œμ‹  버전을 μ‚¬μš©ν•˜κ±°λ‚˜ μ„€μΉ˜ μ‹œ μˆ˜λ™μœΌλ‘œ μˆ˜μ •ν•΄μ•Ό ν•˜λŠ” 버그가 μžˆμŠ΅λ‹ˆλ‹€. https://github.com/vgrem/Office365-REST-Python-Client/blob/master/office365/sharepoint /files/file.py#L275

λ²„μ „μ—μ„œ ctx.service_root_url λŠ” μ†μ„±μ΄μ§€λ§Œ ctx.service_root_url() λ©”μ„œλ“œμ—¬μ•Ό ν•©λ‹ˆλ‹€.

λͺ¨λ“  4 λŒ“κΈ€

2.2.1 λ²„μ „μ—λŠ” git의 μ΅œμ‹  버전을 μ‚¬μš©ν•˜κ±°λ‚˜ μ„€μΉ˜ μ‹œ μˆ˜λ™μœΌλ‘œ μˆ˜μ •ν•΄μ•Ό ν•˜λŠ” 버그가 μžˆμŠ΅λ‹ˆλ‹€. https://github.com/vgrem/Office365-REST-Python-Client/blob/master/office365/sharepoint /files/file.py#L275

λ²„μ „μ—μ„œ ctx.service_root_url λŠ” μ†μ„±μ΄μ§€λ§Œ ctx.service_root_url() λ©”μ„œλ“œμ—¬μ•Ό ν•©λ‹ˆλ‹€.

@efremovd 와 @etiennecelery κ°€ 그것을 μž‘μ•„λ‚΄κ³  μ •ν™•νžˆ μ§€μ ν•΄μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. μ‹€μ œλ‘œ 이것은 버그이며 service_root_url 속성을 λ©”μ†Œλ“œλ‘œ λ¦¬νŒ©ν† λ§ν•˜κΈ° λ•Œλ¬Έμ— 2.2.1 λ²„μ „μ—μ„œ λ°œμƒν•©λ‹ˆλ‹€.

μ–ΈκΈ‰ν–ˆλ“―μ΄ GitHubμ—μ„œ μ‚¬μš©ν•  수 μžˆλŠ” _latest_ 버전은 이 문제λ₯Ό ν•΄κ²°ν•©λ‹ˆλ‹€.

pip install git+https://github.com/vgrem/Office365-REST-Python-Client.git

λ˜λŠ” μ•„λž˜μ™€ 같이 νŒŒμΌμ„ λ‹€μš΄λ‘œλ“œν•  수 μžˆμŠ΅λ‹ˆλ‹€.

file_url = '{server-relative-path-to-download}'
with open(download_path, "wb") as local_file:
    file = ctx.web.get_file_by_server_relative_url(file_url).download(local_file).execute_query()

κ°μ‚¬ν•©λ‹ˆλ‹€!! ν›Œλ₯­ν•œ 일

이후에 이것을 λ‹«λŠ” 것이 ν•΄κ²°λ˜μ—ˆμœΌλ©° 2.2.2 버전이 μΆœμ‹œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰