如何检查文件大小和大小的大小反应原生



Hy,我正在从API获取图像的详细信息,但我如何检查文件的大小和维度。我正在使用Axios获取数据?

由于API返回URI,因此可以使用Image组件获取维度

Image.getSize(uri, (width, height)=>console.log(width,height)) 

对于大小,您可以使用fetch或Axios和图像URI,然后检查返回的请求。你可以在得到图像URI 后直接添加

fetch(uri).then(response => console.log(response.headers.get("content-length")))

您可以使用以下代码获取图像大小

const myUri= "https://cdn.pixabay.com/photo/2015/03/04/22/35/head-659652_960_720.png";
Image.getSize(myUri, (width, height)=>console.log("image size",width,"x",height)) 

最新更新