Universal File Sharing: File messages enable seamless document and attachment sharing across all file types. From documents and spreadsheets to custom files, provide comprehensive file sharing capabilities with automatic validation and progress tracking.

File Messaging Overview

File messages provide comprehensive document and attachment sharing capabilities, allowing users to share any type of file with automatic upload processing, size validation, and cross-platform compatibility.

Universal Support

Any file type sharing
  • Documents (PDF, DOC, XLS, PPT)
  • Archives (ZIP, RAR, 7Z)
  • Code files and text documents
  • Custom file types and formats

Smart Processing

Intelligent file handling
  • Automatic size validation
  • Format detection and validation
  • Progress tracking during upload
  • Error handling and recovery

Platform Implementation

Unified file handling with automatic uploadMobile SDKs provide streamlined file messaging with automatic upload processing and validation, eliminating the need for separate upload steps.

Required Parameters

ParameterTypeDescription
subChannelIdStringTarget subchannel identifier for the file message
attachmentFile/URILocal file path or URI reference

Optional Parameters

ParameterTypeDescription
fileNameStringCustom filename for the uploaded file
captionStringText description or context for the file
tagsArray<String>Message categorization and filtering tags
parentIdStringParent message ID for threaded conversations
metadataObjectCustom properties for extended functionality

Implementation Examples

// Create file message with local file
let fileUrl = URL(fileURLWithPath: "/path/to/document.pdf")
let options = AmityFileMessageCreateOptions(
    subChannelId: "subChannel-123",
    attachment: .localURL(url: fileUrl),
    fileName: "project_proposal.pdf",
    caption: "Updated project proposal with Q1 timeline 📄",
    tags: ["proposal", "project", "q1-planning"],
    parentId: nil
)

do {
    let message = try await messageRepository.createFileMessage(options: options)
    print("File message sent: \(message.messageId)")
    
    // Access file details
    if let fileData = message.data as? AmityMessageFileData {
        print("File name: \(fileData.fileName)")
        print("File size: \(fileData.fileSize) bytes")
        print("MIME type: \(fileData.mimeType)")
    }
} catch {
    // Handle upload or creation error
    print("Failed to send file: \(error)")
}
Automatic Validation: Mobile SDKs automatically validate file size limits and handle upload processing with progress tracking and error recovery.

File Message Features

Implementation Strategy: Start with basic file messaging using platform-specific patterns (unified upload for mobile, two-step for web), then add validation, progress tracking, and security features. Always implement proper file type validation and size limits to ensure system stability and security.