I have a web app that allows users to upload an attachment with the map note they draw on the map. That seems to work as expected. but once I have attachments, I do not see logically where they should be accessed & how they can be related to the GDB that contains the feature classes to which the attachments belong.
My uploaded attachments are visible at the REST endpoint, such as
//myserver/arcgis/rest/services/Folder/ServiceName/FeatureServer/1/26/attachments
I also see that the attachments are in the following folder on my AGS machine:
\\arcgisserver\directories\arcgissystem\arcgisuploads\scratch- all attachments are seen here
My question now is how to make the connection between the scratch folder contents (with long numeric file names) and my attachments? I can click on the REST endpoint to get them. They are also listed in the ATTACH table in my SQL GDB that is the managed database for my data. But I do not see the connection between the two.
I also see some non-image attachments here:
\\arcgisserver\directories\arcgisoutput\Folder\ServiceName_MapServer
I would like to be able to have some way to more easily find the attachments on my server after users upload content. Right now there does not seem to be a way to relate the files by name or other field.
Please help me untangle the web.....thanks
Solved! Go to Solution.
Try the following for the tbl variable:
tbl = r'Database Connections\Connection to TPBData.sde\TPBData."COGMASTER\AGS".BikeBeltway_inner__ATTACH'
Also, create the 'C:\Temp\Attachments' directory on your machine.
Hi C E,
Take a look at the relationship class properties (right-click > Properties) between the feature class an attachment table. It will tell you the fields used for the relationship. Ex:
Thanks for the response. This is not what I am asking exactly. I am trying to figure out how to actually use the attachments that are uploaded by users when editing. The files are accessible at the REST endpoint by the name that the user gives. However, the only place I have been able to physically find the files (as in storage location other than a URL) is in the scratch folder I mention above. The only thing in the attach table is the REL_OBJECTID like you mention, that relates to the position in REST where the attachment resides. But there is nothing in the files themselves anywhere that I can easily download and assign a particular file to a record since the scratch files do not have the REL_OBJECTID.
Do these attachments with useful names/IDs live anywhere other than REST? If not, how can I collect these attachments besides manually? thanks
You can use the following script to download all of the attachments. The attachment name will match the name of the ATT_NAME field in attachments table:
import os, arcpy tbl = r"C:\Projects\SQLServer.sde\VECTOR.VECTOR.Graffiti__ATTACH" fldBLOB = 'DATA' fldAttName = 'ATT_NAME' outFolder = r"C:\Temp\Attachments" with arcpy.da.SearchCursor(tbl,[fldBLOB,fldAttName]) as cursor: for row in cursor: binaryRep = row[0] fileName = row[1] # save to disk open(outFolder + os.sep + fileName, 'wb').write(binaryRep.tobytes()) print 'Finished'
Thanks for the script. I tried running it and got a syntax error on the 2nd line....think it was because the data owner name was in quotes. So I changed it to this (was "COGMASTER\AGS" before)
... tbl = r"C:\Users\choward\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Connection to TPBData.sde\TPBData.COGMASTER\AGS.BikeBeltway_inner__ATTACH"
After that, nothing seems to happen. I do not use python much so maybe I am just missing a simple thing. I copied the code into the python window in Catalog, maybe I should save as a file and run somewhere/how?
thanks
Do you have the 'outFolder' path created on your server? In the example, the attachments are being written to 'C:\Temp\Attachments'. Make sure this folder exists.
yes, I have that folder already created. I am thinking its something with my SDE connection string, but this is the location for it....only difference is the quotes as mentioned above. I am going to copy the string again and try one more time.....stay tuned
Should I log this as an official support case? only hesitation there is it usually takes longer to get a response. But I need to figure out how to use the attachments people will be providing (any day now, my app goes live next week)
This time I get this
Runtime error
Traceback (most recent call last):
File "<string>", line 7, in <module>
RuntimeError: cannot open 'C:\Users\choward\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Connection to TPBData.sde\TPBData.COGMASTER\AGS.BikeBeltway_inner__ATTACH'
I should mention that the C drive in this line is my workstation, and the C:\temp is on my server machine
Can you send a screen shot of how the attachment appears in your catalog window?
Thanks for the response....here is the attachment table. I only see the attachments via the REST endpoint or in the scratch folder