0

嗨,我尝试使用 expo 上传文件:console.log 给我这个错误“流式文件上传req.file()只能通过 HTTP 与 Skipper 可用”但是当我使用邮递员尝试它时它是有效的。我使用sailsJs 作为我的后端这是我的博览会代码反应

const[imageUri, setImageUri]=useState()
    const[imageUpload, setImageUpload]=useState()
    const selectImage = async()=>{
        try {
            const result = await ImagePicker.launchImageLibraryAsync();
            if(!result.cancelled)
            setImageUri(result.uri)
            setImageUpload(result)
        } catch (error) {
            console.log('Error running on image')
        }
       
    }
const handleSubmit = async () => {
        const dataDemande = {
            projectTitle: titre,
            material: materiel,
            description: description,
            projectType: checked,
            lieuRendezvous: value_3,
            idClient: props.route.params.id,
            model: imageUpload
        };
        console.log(dataDemande);
        var res = await demandeClient(dataDemande);
        console.log(res);
        props.navigation.navigate("Tableau de bord - Client");
    };

这是来自后端的代码

findCouturierAndCreateDemande: async function (req, res) {
    var recherche = req.body
    req.file('model').upload({
      adapter: require('skipper-gridfs'),
      uri: 'mongodb://localhost:27017/image'
    }, async function (err, filesUploaded) {
      if (err) return res.serverError(err);
      console.log(filesUploaded[0].fd)
      var couturier = await Client.find({
        where: {
          isCouturier: true,
          ville: { contains: recherche.ville },
          adresse: { contains: recherche.adresse },
          rue: { contains: recherche.rue },
        },
      })
      var img = await Image.create(_.omit(filesUploaded[0], ['status', 'field', 'extra'])).fetch()
      var newDemande = await Demande.create({
        titre: recherche.projectTitle,
        materiel: recherche.material,
        description: recherche.description,
        service: recherche.projectType,
        positionActivity: recherche.lieuRendezvous,
        client: recherche.idClient,
        modelImage: img.id
      }).fetch()
      console.log(img)
      return res.ok({couturier, newDemande})
    });
  }
4

0 回答 0