Adding attachment with long name causes size to be zero.

422
2
Jump to solution
01-23-2019 11:40 AM
deleted-user-7asiru_Gs_LV
New Contributor II

Hello,

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;‍‍

Cheers,

Jeff

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor

Hi,

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

Regards

Mike

View solution in original post

0 Kudos
2 Replies
PreetiMaske
Esri 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

MichaelBranscomb
Esri Frequent Contributor

Hi,

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

Regards

Mike

0 Kudos