Skip to content

Create abstractions for handling files and media #56

@austin-carnahan

Description

@austin-carnahan

Recent changes to saving and retrieving media files changed task and upload implementation to use relative paths. This fixes a bug where the APP ID or BUILD ID in the absolute paths of media files saved to the device cache directory change between app updates.

This bug fix also introduces tighter coupling between the task implementations where media files are initially saved and the media upload implementation in SurveyDataContext making it more difficult for other developers to implement new tasks without knowledge of file storage conventions.

Decoupling these things using handlers and utility methods for media would improve this issue and abstract it away from new task development. See recommendations:

  1. Centralize File Management
    Create a FileService module to handle all file-related operations (e.g., saving, resolving, deleting).
    This ensures consistent handling of paths (absolute and relative) across the app.
  2. Abstract Media Handling
    Create a MediaManager module to encapsulate both file management and upload logic.
    This module should provide high-level methods like saveMedia, uploadMedia, and deleteMedia.
  3. Use Configuration for Directories
    Define a configurable MEDIA_DIRECTORY (e.g., FileSystem.cacheDirectory) to avoid hardcoding paths.
    Update all file operations to use this directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions