Giter VIP home page Giter VIP logo

Comments (4)

JohnCoene avatar JohnCoene commented on June 26, 2024 1

Maybe I should switch that in ambiorix and/or document this.

Thanks for looking into this!

from ambiorix.

kennedymwavu avatar kennedymwavu commented on June 26, 2024

I've also tried using Rook::Multipart$parse(req) and it's also that slow.

#' Handle POST on '/upload'
#'
#' @param req Request object.
#' @param res Response object.
#' @export
file_upload <- \(req, res) {
  total_time <- system.time({
    body <- Rook::Multipart$parse(req)
  })

  print(total_time)

  html <- tags$p(
    class = "text-success",
    "File uploaded successfully!"
  )
  res$send(html)
}

image

I'm not sure anymore if this issue belongs here.

from ambiorix.

kennedymwavu avatar kennedymwavu commented on June 26, 2024

webutils::parse_*() functions are exactly what I was looking for! They offer the parsing speeds you'd expect.
Leaving this POC here for posterity:

#' Handle POST on '/upload'
#'
#' @param req Request object.
#' @param res Response object.
#' @export
file_upload <- \(req, res) {
  content_type <- req$CONTENT_TYPE
  body <- req$rook.input$read()

  postdata <- webutils::parse_http(body, content_type)

  # print the parsed data:
  utils::str(postdata)

  # write the uploaded file locally (POC):
  file_path <- file.path(
    getwd(),
    basename(postdata[["file"]][["filename"]])
  )

  writeBin(object = postdata$file$value, con = file_path)

  html <- tags$p(
    class = "text-success",
    "File uploaded successfully!"
  )
  res$send(html)
}

from ambiorix.

kennedymwavu avatar kennedymwavu commented on June 26, 2024

Ideally, having both options would be great.
Though IMO documenting carries more weight since it will demonstrate that one can use a different parser (or even build one) that suits their needs.

Welcome! I enjoyed every bit of the search.

from ambiorix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.