FixUploading Issues on newpost
This commit is contained in:
@@ -29,27 +29,31 @@ let ProfileSettings = ()=>{
|
||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||
allowsEditing: true,
|
||||
aspect: [4, 3],
|
||||
quality: 0.7,
|
||||
quality: 0.2,
|
||||
//allowsMultipleSelection: true,
|
||||
});
|
||||
if (!result.cancelled) {
|
||||
if (!result.canceled) {
|
||||
setPhoto(result);
|
||||
let newPhotoURL = await handleUploadPhoto(result);
|
||||
let newPhotoURL = await handleUploadPhoto(result.assets[0]);
|
||||
if(newPhotoURL !== ""){
|
||||
setphotoUrl(newPhotoURL);
|
||||
GlobalState.me.profile.photo = newPhotoURL;
|
||||
setUpdateKey(updateKey+1);
|
||||
viewer.profile.photo = newPhotoURL;
|
||||
setUpdateKey(updateKey + 1);
|
||||
}
|
||||
setPhoto(null);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUploadPhoto = async (photo) => {
|
||||
console.log(photo)
|
||||
if (!photo) return;
|
||||
const uri =
|
||||
Platform.OS === "android"
|
||||
? photo.uri
|
||||
: photo.uri.replace("file://", "");
|
||||
|
||||
console.log(uri);
|
||||
const filename = photo.uri.split("/").pop();
|
||||
const match = /\.(\w+)$/.exec(filename);
|
||||
const ext = match?.[1];
|
||||
@@ -69,9 +73,10 @@ let ProfileSettings = ()=>{
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
console.log(data);
|
||||
return data.fileName;
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
});
|
||||
console.log(uploadedFile);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
alert("Something went wrong uploading the photo.");
|
||||
|
||||
Reference in New Issue
Block a user