AnsweredAssumed Answered

Adding attachment with long name causes size to be zero.

Question asked by deleted-user-7asiru_Gs_LV on Jan 23, 2019
Latest reply on Sep 13, 2019 by MBranscomb-esristaff



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;