load static method

Loads a remote attachment by fetching, decrypting, and parsing it

This method handles the complete flow of:

  1. Fetching the encrypted payload from the remote URL
  2. Verifying the content digest (SHA-256)
  3. Decrypting the payload using AES-GCM
  4. Parsing the decrypted bytes as an AttachmentContent

Note: This method does NOT handle caching. The caller is responsible for checking cache before calling this method and storing the result afterward.

Implementation

static Future<AttachmentContent> load(RemoteAttachmentContent content) async {
  try {
    print('RemoteAttachment: Fetching from network');
    final attachment = await _fetchDecryptAndParse(content);
    return attachment;
  } catch (e) {
    print('Error loading remote attachment: $e');
    rethrow; // Rethrow to preserve stack trace
  }
}