Uploadex v0.1.2 Uploadex View Source
Context Helper functions for handling files.
Link to this section Summary
Functions
Inserts the changeset and store the record files in a database transaction, so if the files fail to be stored the record will not be created.
Deletes the record and all of its files. This is not in a database transaction, since the delete operation never returns errors.
Returns the record's files (as defined in the definition get_files
) URL, replacing the uploader.base_directory()
with the endpoint URL.
Similar to get_files_url/3
, but instead of returning all files defined in the definition get_files
, returns the URL for the specified files.
Similar to update_with_file/3
, but does not delete previous files.
Updates the record and its files in a database transaction, so if the files fail to be stored the record will not be created.
Link to this section Functions
create_with_file(changeset, uploader) View Source
Inserts the changeset and store the record files in a database transaction, so if the files fail to be stored the record will not be created.
delete_with_file(record, uploader) View Source
Deletes the record and all of its files. This is not in a database transaction, since the delete operation never returns errors.
get_files_url(uploader, record, endpoint_url) View Source
Returns the record's files (as defined in the definition get_files
) URL, replacing the uploader.base_directory()
with the endpoint URL.
To provide the endpoint URL, there are two options:
- Provide the
endpoint_url
directly as a string - Provide the
Phoenix.Endpoint
module
get_files_url(uploader, record, files, endpoint_url) View Source
Similar to get_files_url/3
, but instead of returning all files defined in the definition get_files
, returns the URL for the specified files.
This is useful when one record has multiple file fields.
update_with_file(changeset, uploader) View Source
Similar to update_with_file/3
, but does not delete previous files.
update_with_file(changeset, previous_record, uploader) View Source
Updates the record and its files in a database transaction, so if the files fail to be stored the record will not be created.
This function also deletes files that are no longer referenced.