Select to view content in your preferred language

Adding attachment with long name causes size to be zero.

Jump to solution
01-23-2019 11:40 AM
New Contributor II


I am using version 100.4 of the ArcGIS .NET runtime.

I have noticed that attachments with names longer than 40 characters (not including the file extension) will always have a size of zero when returned from ArcGISFeature.GetAttachmentAsync(). Note: An attachment name longer than 40 characters appears to be truncated to 40 characters. Here is an example:

// Name is truncated to "Google Play Distribution Agreement (SP C.pdf"
await myFeature.AddAttachmentAsync("Google Play Distribution Agreement (SP Comments).pdf", "application/pdf", <attachmentData>);

await myFeature.FeatureTable.UpdateFeatureAsync(myFeature);
if (myFeature.FeatureTable is ServiceFeatureTable serviceFeatureTable)
      var editResults = await serviceFeatureTable.ApplyEditsAsync();
      var featureResult = (FeatureEditResult)editResults.FirstOrDefault();
      var attachmentResult = featureResult.AttachmentResults.First();       
      var id = attachmentResult.ObjectId;
      var allAttachments = await myFeature.GetAttachmentsAsync();

      // This will have a size of 0
      var myAttachment = allAttachments.FirstOrDefault(a => a.Id == id);             

If you rename the same file to have name shorter than 40 characters, the size will be set correctly. I have attached the offending file.

This only occurs after the attachment was added to the feature. If the attachment already exists on myFeature then GetAttachmentsAsync() returns the attachments with correct sizes. The attachment returned from AddAttachmentAsync() has the correct size, but of course does not have the correct id yet. I managed to work around this by doing something like this:

var data = await attachment.GetDataAsync(); 
var size = data.Length;‍‍



Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Esri Frequent Contributor


This issue was fixed in v100.6 of ArcGIS Runtime SDK for .NET.



View solution in original post

0 Kudos
2 Replies
Esri Regular Contributor

Hello Jeff,

Thanks for notifying about size for attachments with filenames greater than 40 characters. I am able to repro the problem and have logged a bug to address in future release. I am glad at least you have a workaround.

Again, thanks for bringing this to out attention. Let me know if you have any further questions on this.

-- Preeti

Esri Frequent Contributor


This issue was fixed in v100.6 of ArcGIS Runtime SDK for .NET.



0 Kudos