From 753e7d129289490a2a52d1d21ab63f0c363c2d76 Mon Sep 17 00:00:00 2001 From: Danilo Grieco Date: Tue, 2 Jul 2024 18:54:52 +0200 Subject: [PATCH] Handle also path in the response for a get --- lib/sharepoint/client.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sharepoint/client.rb b/lib/sharepoint/client.rb index 207d015..1616d0e 100644 --- a/lib/sharepoint/client.rb +++ b/lib/sharepoint/client.rb @@ -280,12 +280,13 @@ def list_documents_page(url) # - `:link_url` [String] if the requested file is a link, this returns the destination file url def download(file_path: nil, site_path: nil, link_credentials: {}) meta = get_document(file_path, site_path) - if meta.url.nil? + meta_path = meta.url || meta.path + if meta_path url = computed_web_api_url(site_path) server_relative_url = odata_escape_single_quote "#{site_path}#{file_path}" download_url "#{url}GetFileByServerRelativeUrl('#{server_relative_url}')/$value" else # requested file is a link - paths = extract_paths(meta.url) + paths = extract_paths(meta_path) link_config = { uri: paths[:root] } if link_credentials.empty? link_config = config.to_h.merge(link_config) @@ -293,7 +294,7 @@ def download(file_path: nil, site_path: nil, link_credentials: {}) link_config.merge!(link_credentials) end link_client = self.class.new(link_config) - result = link_client.download_url meta.url + result = link_client.download_url meta_path result[:link_url] = meta.url if result[:link_url].nil? result end