前の質問hereコミュニティから助けを受けて、結果のbase64文字列をsrc属性として設定しましたが、画像の1つまたは複数の画像には画像の下部がありません。下の画像をご覧ください。以下はなぜ私のbase64文字列は自分の写真の一部にしか表示されませんか?
私は画像の内容を設定するために使用しているコードです。画像の残りの部分を表示するにはどうしたらいいですか?
import React from 'react';
import axios from 'axios';
import * as settings from './settings';
export default class Post extends React.Component {
constructor(){
super();
this.state = {
profileImage:'img/loading.gif'
};
}
componentDidMount(){
if(this.props.post.PostImageId != "00000000-0000-0000-0000-000000000000"){
// get post image data
_rvw.getImage(this.props.post.PostImageId)
.then((res)=>{
this.setState({
postImage: "data:" + res.headers["content-type"] + ";base64," + res.data
});
});
}
else //no image
{
this.setState({
postImage: "img/no-image.png"
});
}
}
getImage(id){
let config = {
headers:{
'Content-Type': 'application/json',
'Accept':'application/json',
'Authorization':'Bearer ' + localStorage.token
}
};
return axios.get(settings.baseUrl()+'/mediacontent/get/'+id,config);
}
render(){
return (<div className="image">
<img ref="postMedia" src={this.state.postImage} />
</div>);
}
}
全成分がhere見出すことができます。あなたのポストに基づいて
最初に受信したデータが完全であることを確認します。 – zerkms
無関係ですが、依然として:btw、 'this.props.post.ProfileImageId!= null'チェックが重複している可能性があります。 – zerkms
サイズを二重に確認しても問題ありません。紺碧のブロブは289.9kbで、私はhttpレスポンスから290kbを受け取っています。 – chesco