问题描述
很高兴有人可以满足以下要求。
const storage = multer.memoryStorage()
const upload = multer({
storage: storage
})
const FileType = require('file-type')
app.post('/uploadfile',upload.single('file'),async (req,res) => {
console.log(Object.keys(req.file))
console.log(await FileType.fromBuffer(req.file.buffer));
res.send()
}) `
需求详细信息:-
想要将“类别/提供者”属性值的值连接到名为“ Category_provider”的新列下,不幸的是,它没有在UI表中显示属性名称,而是代替了这些值。为了达到要求,我的代码中将进行哪些更正。
解决方法
尝试一下,
url <- "https://bbolker.github.io/mpha_2019/gapminder_index.csv"
dt <- as.data.frame(fread(url))
# UI
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
textInput("newcolumnname","Custom Attribute Name"),selectInput("formula","Enter Custom Formula",choices = unique(names(dt)),multiple = TRUE),actionButton("addnewcolumn","Add new column")
),mainPanel(
DT::DTOutput("data_tbl")
)
)
)
#SERVER
server <- function(input,output,session) {
reactive_dt <- eventReactive(input$addnewcolumn,{
if (input$newcolumnname != "" &&
!is.null(input$newcolumnname) && input$addnewcolumn > 0) {
newcol <- apply(dt[,input$formula],1,function(x) paste(x,collapse = "_"))
cn <-colnames(dt)
dt <<- data.frame(dt,newcol)
colnames(dt) <- c(cn,input$newcolumnname)
}
dt
})
output$data_tbl <- DT::renderDT({ head(reactive_dt(),5) })
}
#Run the Shiny App to Display Webpage
shinyApp(ui = ui,server = server)