簡體   English   中英

Feathers js在postman中使用原始json上傳文件

[英]Feathers js upload file using raw json in postman

我們如何配置feathers js來支持form-data? . 基本上我目前的實現現在支持原始 json,但我有一個功能,我必須將文件上傳到亞馬遜存儲桶,並且像使用 postman 一樣上傳文件的唯一方法是支持表單數據。 謝謝

在此處輸入圖像描述

或者像有沒有一種方法可以在不使用表單數據的情況下上傳文件? 喜歡在郵遞員中使用 raw 嗎? (已編輯)

對於這些類型的文件上傳,您需要一個額外的中間件來處理multipart/form-data上傳 - 通常使用multer 以下是一些可以幫助您入門的示例代碼:

const multer = require('multer');
const fileUploadHandler = multer();

// Upload Service with multipart support
app.use('/photos',    
    // you can define different storage options, the default is to keep the uploaded data in memory
    fileUploadHandler.single('filename'),
    function(req,res,next){
        // the uploaded file is accessible now under req.file
        next();
    }
); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM