FixUploading Issues on newpost

This commit is contained in:
Adolfo Reyna
2023-08-24 22:29:59 -04:00
parent e539e05c6e
commit bdbf2f63c1
5 changed files with 56 additions and 217 deletions

View File

@@ -42,10 +42,10 @@ let NewPostView = (props) => {
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 newPhotoURLs = await handleUploadPhoto(result);
let newExtraContent = [extraContent]

View File

@@ -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.");