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);
}
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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