从node / express api从Dropbox下载文件/将文件上传到Dropbox,以分离php应用程序

问题描述 投票:0回答:0

嘿,我还没有找到任何信息,但是我想要实现的是使用Express / Node Rest API,该API将使用Dropbox JS SDK将文件发送到主要是PHP的不同应用程序,这可能吗? 我一直在玩弄它,不确定自己是否走上了最好的路

API代码

router.post('/', async (req, res) => {


    var dbx = new Dropbox({ accessToken: '<key>', fetch: fetch });
    dbx.filesDownload({path: "/large_vid.mp4"})
        .then(function (resp) {
            let data = resp[Object.keys(resp)[11]];
            res.status(201).send(data);
        })
        .catch(function (errs) {
            console.log(errs);
            res.status(203).send(errs);
        });
});


module.exports = router;

PHP代码

      $ch = curl_init();

      curl_setopt($ch, CURLOPT_URL, $url);

      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
            'Content-Type: application/json',                                                                                
            'Content-Length: ' . strlen($postData))                                                                       
        );

      curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

      $response = base64(curl_exec($ch));


php node.js express dropbox dropbox-js
© www.soinside.com 2019 - 2024. All rights reserved.