NIFCLOUD-mbaas / ncmb_js

ニフクラ mobile backend JavaScript SDK
https://mbaas.nifcloud.com
Other
28 stars 27 forks source link

issue #260: File.downloadがエラーとなります #263

Closed vfa-tamhh closed 3 years ago

vfa-tamhh commented 3 years ago

概要(Summary)

動作確認手順(Step for Confirmation)

On Monaca Ev:

new NCMB(appKey, clientKey).File.download("sample.txt")
.then(function(data) {
    console.log("File.download success data: " + data);
})
.catch(function(err) {
    console.log("error : " + err.message);
    console.log("error stack: " + err.stack);
})

On NodeJS Ev:

var NCMB = NCMB || require("./lib/ncmb");
var ncmb = new NCMB(appKey, clientKey);
const fs = require('fs');
var fileName = "sample";
// png, jpg, pdf, zip, xlsx, mp4, mp3, json, txt
var extension = ".txt";
fileName = fileName + extension;

ncmb.File.download(fileName)
    .then(function(fileData){
      // ファイル取得後処理
      fs.writeFile(fileName, fileData, function(error){
          if (error) {
            console.log(error);
          } else {
            console.log('success');
          }
      });
     })
    .catch(function(err){
      // エラー処理
      console.log(err);
     });