Programming API MediaFile

Navigate

    MediaFiles are images, documents, videos or audio files that can be attached to Observations.

    Attributes

    Parameter Type Description
    id int Identifies file in the data base.
    name string Title of the file.
    description string Long-form caption of the image.
    contribution Observation Observation this file is assigned to.
    creator User User who added the file.
    created_at datetime Date and time when the file was added.
    status string Status of the file. Must be one of active, deleted. Defaults to active.

    File-specific attributes

    ImageFile
    Parameter Type Description
    image ImageFile Image uploaded.
    DocumentFile
    Parameter Type Description
    document File Document uploaded.
    thumbnail ImageFile Thumbnail image of the document.
    VideoFile
    Parameter Type Description
    video File Video uploaded.
    youtube_id string ID of the video uploaded to YouTube.
    thumbnail ImageFile Thumbnail image of the video.
    youtube_link URL Embedable link to the youtube video.
    AudioFile
    Parameter Type Description
    audio File Audio file uploaded.

    Read-only properties

    Property Type Description
    type_name string Indicates the file type. Is one of ImageFile, DocumentFile, VideoFile, AudioFile

    Methods

    delete()

    Deletes a MediaFile by setting its status to deleted.

    Creating a model instance

    MediaFile.objects.create(name=None, description=None, creator=None, contribution=None, the_file=None)

    Creates a new file. It examines the content type of the file and creates the appropriate MediaFile instance.

    Parameters
    name: string
    Title of the file
    description: string
    Long-form caption of the image
    creator: User</dt>
    User who adds the file
    contribution: Observation</dt>
    Observation this file is assigned to
    the_file: File
    File object representing the file.
    </dl> ##### Returns
    ImageFile
    if an image was uploaded
    DocumentFile
    if a document was uploaded
    VideoFile
    if an video was uploaded
    AudioFile
    if an audio file was uploaded
    ##### Raises
    FileTypeError
    if an unsupported file type was uploaded