Items of type "Code Attachment"

10751
17
Jump to solution
03-06-2019 02:04 AM
Nicole_Ueberschär
Esri Regular Contributor

When I look through my content in AGO assistant or with the Python API for ArcGIS for example, I find a couple of files of the type "Code Attachment". When I look into the item details I can't find any valuable information. For what are these files needed?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KellyGerrow
Esri Alum

Hi Michael,

The purpose of the code attachment is to hold and storing and downloading code. IT is not intended for use when executing custom code referenced in the code attachment.

Thanks,

Kelly

View solution in original post

0 Kudos
17 Replies
KellyGerrow
Esri Alum

Code samples are a type of item that includes a script. This is used to help users easily find code samples in ArcGIS Online.

These item types are indexed and displayed through this website:

ArcGIS Code Sharing 

-Kelly

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

I assume they would only show on that page if I would share them publicly. 

If I don't share them with anybody are those files still somehow necessary or could I delete them?

0 Kudos
KellyGerrow
Esri Alum

Please check reply below for updated information.

Yes correct they will only appear if on the code sharing website if they are shared publicly.

You can delete the files at any time if you don't use them. They are just another item type for sharing. 

-Kelly

0 Kudos
KellyGerrow
Esri Alum

Hi Nicole,

My kind colleague Chris Whitmore‌, informed me that I am mixing up two item types being code samples and code attachments. I'll use this post to differentiate between the two.

A Code Attachment is a related to a Web Application Item type that is hidden from the content view in ArcGIS Online but is queryable by AGO-Assistant and the Python API. This can be used to include code (as a zipfile) for users to download and have access to your code for a configurable app or other sample.

Code Attachment—You can attach code (as a ZIP file) to your apps. This can be helpful if you are sharing a sample or a configurable app and want others to have access to your code.

To update a code attachment without resetting the download counter on the item, use Update Code and upload a ZIP file with the same name as the original ZIP file. If you want to attach a new file, first delete the existing file; then use Attach Code. This will reset the download count on the item.

Item details—ArcGIS Online Help | ArcGIS 

This is an optional component, but if you have added it to an item, I think it be something that you want to keep.

Code Samples are a different but similar item type that can be seen in My Content. As they are standalone code samples unrelated to other content they can be seen in the Code Sharing website. Again, you can delete this, but it may be needed if this was specifically uploaded for sharing code samples:

Add items—ArcGIS Online Help | ArcGIS 

Let us know about any other questions,

-Kelly

MichaelHeavenor
Emerging Contributor

The documentation states what Code Attachment could be used for ("helpful if you are sharing a sample or a configurable app...") but it isn't clear on what it must be used for.

For example, I host a Javascript application on my own domain which does the following:

1) Fetches a Web Mapping Application item from ArcGIS Online

2) Reads the content of this item (the item's content is JSON configuration for my app which includes a reference to a WebMap

3) Applies the configuration that was read from step 2

4) Displays the referenced WebMap.

My scenario involves wanting my app to provide some additional tools when interacting with the WebMap. I have decided to factor out this Javascript code separately from my main Javascript application for my own reasons. If I zip up my factored out Javascript that provides the additional functionality, attach it as a Code Attachment to the Web Mapping Application referenced in step 1, my steps above would become the following:

1) Fetches a Web Mapping Application item from ArcGIS Online

2) Reads the content of this item (the item's content is JSON configuration for my app which includes a reference to a WebMap

3) Download the Code Attachment Zip in the browser

4) Applies the configuration that was read from step 2

5) Unzip the Code Attachment in the browser and run the containing Javascript

6) Display the referenced WebMap with additional tools provided by the Javascript from step 5.

Is this an acceptable use of the Code Attachment item?

Thank you

KellyGerrow
Esri Alum

Hi Michael,

The purpose of the code attachment is to hold and storing and downloading code. IT is not intended for use when executing custom code referenced in the code attachment.

Thanks,

Kelly

0 Kudos
DeborahCohen2
Occasional Contributor

I also have this question. Several of these items showed up in my Gallery of apps just in the past couple weeks. I didn't add them. All of these apps were built using ESRI apps or web app builder. No coding. Where did they come from and can I delete them?

Thanks

0 Kudos
KellyGerrow
Esri Alum

Can you share your application? No updates have gone out so it is strange that they just started appearing.

IanMooser
Occasional Contributor

Hi Deborah and Kelly - I'm getting a similar behavior in the Category Gallery.  Page 3 and 4

https://seattlecitygis.maps.arcgis.com/apps/FilterGallery/index.html?appid=bbb9afe638c9460bb13a31aac...

Kelly Gerrow‌ Deborah Cohen