<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Rendering Volumes file content programmatically in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/99807#M40103</link>
    <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;I have some files stored in Volume, and I have a use case that I need to show the file content in a UI.&amp;nbsp; Say I have a REST API that already knows the Volume path to the file, is there any built-in feature from Databricks that i can use to help get the content?&lt;/P&gt;&lt;P&gt;one of the &lt;A href="http://The%20DBFS endpoint for the REST API does not support volumes paths." target="_self"&gt;limitations&lt;/A&gt; Unity Catalog Volumes has is: "The DBFS endpoint for the REST API does not support volumes paths.",&amp;nbsp; what does this imply to my use case?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2024 18:47:22 GMT</pubDate>
    <dc:creator>lauraxyz</dc:creator>
    <dc:date>2024-11-22T18:47:22Z</dc:date>
    <item>
      <title>Rendering Volumes file content programmatically</title>
      <link>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/99807#M40103</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;I have some files stored in Volume, and I have a use case that I need to show the file content in a UI.&amp;nbsp; Say I have a REST API that already knows the Volume path to the file, is there any built-in feature from Databricks that i can use to help get the content?&lt;/P&gt;&lt;P&gt;one of the &lt;A href="http://The%20DBFS endpoint for the REST API does not support volumes paths." target="_self"&gt;limitations&lt;/A&gt; Unity Catalog Volumes has is: "The DBFS endpoint for the REST API does not support volumes paths.",&amp;nbsp; what does this imply to my use case?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 18:47:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/99807#M40103</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-11-22T18:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Rendering Volumes file content programmatically</title>
      <link>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/99826#M40111</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133340"&gt;@lauraxyz&lt;/a&gt;&amp;nbsp;here is an example using the Databricks SDK in Python:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;from databricks.sdk import WorkspaceClient

ws = WorkspaceClient()
image_path = '/Volumes/catalog/schema/volume/filename.jpg'

image_data = (
    ws.files.download(image_path) # download file
    .contents # pull out streamed response
    .read() # materialize bytes
)&lt;/LI-CODE&gt;
&lt;P&gt;From here, you can do whatever you like with the image bytes. For example:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;from PIL import Image
from io import BytesIO

image = Image.open(BytesIO(image_data)) # open the image with pillow
image.show() #&lt;/LI-CODE&gt;
&lt;P&gt;If using a different language, we can always use the REST API directly, here is a quick Javascript example that uses the REST API (/api/2.0/fs/files):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Set up API endpoint and headers
const host = "https://..."; // Replace with your workspace URL, leaving the end slash off
const token = "dapi..."; // Replace with your actual Databricks access token
const imagePath = '/Volumes/catalog/schema/volume/filename.jpg';

// Download image using REST API
fetch(`${host}/api/2.0/fs/files${imagePath}`, {
    headers: {
        'Authorization': `Bearer ${token}`
    }
})
.then(response =&amp;gt; response.blob())
.then(blob =&amp;gt; {
    const img = document.createElement('img');
    img.src=URL.createObjectURL(blob);
    document.body.appendChild(img);
})
.catch(error =&amp;gt; console.error('Error:', error));
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2024 21:30:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/99826#M40111</guid>
      <dc:creator>cgrant</dc:creator>
      <dc:date>2024-11-22T21:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rendering Volumes file content programmatically</title>
      <link>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/100005#M40164</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/33816"&gt;@cgrant&lt;/a&gt;&amp;nbsp;this is very helpful!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another related question:&amp;nbsp; if I want to accept user input from a UI and save that into a Volume, how should I do that?&amp;nbsp; I'm referring &lt;A href="https://docs.databricks.com/api/workspace/volumes/create" target="_self"&gt;this&lt;/A&gt; Databricks API doc but it is only to update volume metadata instead of volume files.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 20:18:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/100005#M40164</guid>
      <dc:creator>lauraxyz</dc:creator>
      <dc:date>2024-11-25T20:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rendering Volumes file content programmatically</title>
      <link>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/100006#M40165</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/133340"&gt;@lauraxyz&lt;/a&gt;,&amp;nbsp;the files API should be helpful, particularly the &lt;A href="https://docs.databricks.com/api/workspace/files/upload" target="_self"&gt;upload&lt;/A&gt; endpoint.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2024 20:30:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/rendering-volumes-file-content-programmatically/m-p/100006#M40165</guid>
      <dc:creator>cgrant</dc:creator>
      <dc:date>2024-11-25T20:30:34Z</dc:date>
    </item>
  </channel>
</rss>

