Comments (4)
Maybe I should switch that in ambiorix and/or document this.
Thanks for looking into this!
from ambiorix.
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)
}
I'm not sure anymore if this issue belongs here.
from ambiorix.
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.
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)
- Templates worked for me after one change... HOT 2
- Non-blocking Database Queries within app$get() HOT 3
- Minify HOT 1
- Add a "strengths and weaknesses" section? HOT 2
- Support a res$send variant that doesn't convert data to character? HOT 6
- Content-Type header is overridden by send defaults (doco issue?) HOT 2
- Parse HEADERS
- Better pattern matching HOT 2
- Tests
- Mock Response & Request
- Not available from CRAN anymore ? HOT 3
- Tailwind HOT 1
- Small typo in code HOT 2
- Error handling not working HOT 2
- Pass error to handler HOT 2
- Example on `Ambiorix$start()` has a bug/typo
- error when trying to use custom websocket handler function
- Add a method to set the error handler
- Cache templates
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ambiorix.