From 1f55c8dee6ded1ef942cff5b2e950cf9cedb5b99 Mon Sep 17 00:00:00 2001 From: JBGruber Date: Tue, 16 Jan 2024 16:04:37 +0100 Subject: [PATCH] better way to transform images to raw --- R/utils.r | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/R/utils.r b/R/utils.r index 6c4c6b9..75e98af 100644 --- a/R/utils.r +++ b/R/utils.r @@ -173,10 +173,8 @@ com_atproto_repo_upload_blob2 <- function(image, img <- magick::image_read(image) image_mimetype <- paste0("image/", tolower(magick::image_info(img)$format)) - # TODO: find way to do this directly - tmp <- tempfile() - magick::image_write(img, tmp) - img <- readBin(tmp, "raw", file.info(tmp)$size) + # transform to raw. Thanks Miff! https://stackoverflow.com/a/77824559/5028841 + img <- magick::image_write(img) httr2::request("https://bsky.social/xrpc/com.atproto.repo.uploadBlob") |> httr2::req_auth_bearer_token(token = .token$accessJwt) |>