Notebook Server: Working with "local" content.

114
2
09-17-2021 03:17 PM
DirkVandervoort
Occasional Contributor II

By "local" content, I mean (mostly) files. JPGs, spreadsheets, text files, etc. These artifacts can be obtained requesting a REST endpoint which can return the contents of a file (the binary)

On ArcGIS Notebook Server I would like to obtain a file's binary, and do something with it, like attach it to a feature. 

According to the documentation (https://developers.arcgis.com/python/guide/using-attachments-with-feature-layers/) the attachments.add method requires a path to a file (e.g., C:\\Users\\rohit\\AppData\\Local\\Temp\\AppTemplate.png) , however Notebook Server is not aware of the file system. I've attempted to write the binary to a Python tempfile (https://docs.python.org/3/library/tempfile.html), which successfully writes the file but, it's not usable as an attachment.

Notebook Server on AGOL throws an error of :

Exception: Unable to complete operation.
Adding of attachment failed.
(Error Code: 400)

Executing the on ArcGIS Python API on my local box returns an error of:

[WinError 2] The system cannot find the file specified: 'C:\\Users\\XXXXXXX\\AppData\\Local\\Temp\\tmpikjawae3'

tmpikjawae3 is the name of the file in my temp directory

There are tons of other things I'd like to do: carve into text files, create attachments, connect with automations...

Is what I'm asking about possible?

0 Kudos
2 Replies
DirkVandervoort
Occasional Contributor II

Update:

I've accomplished this with the ArcGIS REST API and a POST and the import requests

What I'd really like to do is use the Python API for ArcGIS: e.g., cr_lyr.attachments.add(1, 'C:\\Users\\rohit\\AppData\\Local\\Temp\\AppTemplate.png')

0 Kudos
ChristopherPawlyszyn
Esri Contributor

Since ArcGIS Notebook Server notebooks run in the context of a Linux container, the two approaches for making files available within the container are to upload to the user's workspace or mount a data directory for all users to access.

 

Work with content in the user workspace—ArcGIS Notebook Server | Documentation for ArcGIS Enterprise
https://enterprise.arcgis.com/en/notebook/latest/use/windows/work-with-content-in-a-user-workspace.h...

Configure ArcGIS Notebook Server directories—ArcGIS Notebook Server | Documentation for ArcGIS Enterprise
https://enterprise.arcgis.com/en/notebook/latest/administer/linux/configure-and-manage-arcgis-notebo...

 

Hopefully that matches up with what you're trying to accomplish.

0 Kudos