之前介绍过上传文件到Supabase
,现在介绍下上传文件到PicGo
…
https://cctv3.net/static/20241211/react-native-upload-to-supabase.html
注意上传的时候,也要Base64
…
完整文档参考:https://v4-docs.chevereto.com/developer/api/api-v1.html#key
假设你的相册链接是,https://www.picgo.net/album/bookkeeping-mobile.SHPRj,那么他的`id`是`SHPRj` …
const uploadImageToPicGo = async () => { if (!image) { Alert.alert("Error", "Please select an image first!"); return; }
setUploading(true); const base64 = await FileSystem.readAsStringAsync(image, { encoding: "base64", }); let instance = axios.create({ baseURL: "https://www.picgo.net", headers: { "X-API-Key": "******", }, }); let formData = new FormData(); formData.append("source", base64); formData.append("album_id", "******"); let result = await instance.post("/api/1/upload", formData); setUploading(false); console.log("result: ", result); };
|