0
Dropboxに格納された.txtファイルの内容を、Dropbox APIを使用して表示することを検討しています。Reactにある.txtファイルのコンテンツを表示する
私はすでにを通して引っ張り、私はjQueryのか、AJAXを使用するか研究して見つけたの例は、すべてのsrc URLの塊に
を作成することにより、画像を表示しています。私はすでにAPIを介してこれらのファイルにアクセスしているので、Dropboxサーバーまで別の呼び出しを行う必要はありませんか?
私はembed
タグを使用しようとしましたが、ブラウザはそのファイルをダウンロードしようとしています。
Dropbox APIを使用して反応するtxtファイルのコンテンツをどのように表示しますか?
class Project extends React.Component{
constructor(){
super();
this.state = {
fileSource: [],
}
}
componentDidMount(){
var that = this;
var sources = [];
var link = "/"+this.props.title;
dbx.filesListFolder({path: link})
.then(function(response) {
...
...
//call to dropbox
...
...
var newUrls=window.URL.createObjectURL(response.fileBlob);
sources.push(newUrls);
})
.then(function(){
that.setState({
fileSource: sources,
});
});
}
});
}
render() {
if(!this.state.fileSource.length)
return null;
let text = this.state.fileSource.map((el, i) =>
<embed src={el}/>
)
return (
<div className="projectWrapper">
{text}
</div>
);
}
}
あなたのコードはファイルメタデータを返す 'filesListFolder'を使ってあなたを示しています。ファイルの内容が必要な場合は、目的のファイルに対して['filesDownload'](https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesDownload__anchor)を呼び出す必要があります。 – Greg