Skip to content

Commit

Permalink
Allow to set MIME type for attached files
Browse files Browse the repository at this point in the history
Fixes #9.
  • Loading branch information
innir authored Aug 10, 2023
1 parent f57bfbc commit ea90ce2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 10 additions & 4 deletions R/mime_part.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,25 @@ mime_part.data.frame <- function(
##'
##' @param x Character string, possibly a filename.
##' @param name Name of attachment.
##' @param type Content type of inline text. Defaults to "text/plain".
##' @param type Content type of inline text. Defaults to "text/plain" for
##' character strings and to "application/octet-stream" for files.
##' @param flowed Should "format=flowed" be added to the content header.
##' @param ... Ignored.
##' @return An S3 \code{mime_part} object.
##'
##' @method mime_part character
##' @export
##' @seealso \code{\link{mime_part_html}} for adding inline HTML
mime_part.character <- function(x, name, type = "text/plain", flowed = FALSE, ...) {
mime_part.character <- function(x, name, type, flowed = FALSE, ...) {
if (length(x) == 1 && file.exists(x)) {
.file_attachment(x, name, ...)
if (missing(type)) {
type = "application/octet-stream"
}
.file_attachment(x, name, type, ...)
} else {

if (missing(type)) {
type = "text/plain"
}
res <- .generate_charset_convert_utf8(x)
format_flowed <- ifelse(flowed, "; format=flowed", "")

Expand Down
5 changes: 3 additions & 2 deletions man/mime_part.character.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea90ce2

Please sign in to comment.