What I’m trying to do
capture an image or upload an image or file using on Branded App.
What I’ve tried so far
Based on Wix API
import { appFramework } from "wix-mobile";
appFramework
.showFileUploadPicker("Image", {
fileLimit: 10,
showCamera: true,
showDeviceMedia: true,
autoUpload: true,
})
.then((result) => {
result.forEach((file) => {
console.log(
${file.fileName} ${file.url ? "successfully" : "was not"} uploaded.
File type: ${file.fileType}
File size: ${file.sizeInBytes}bytes
${
file.url &&
`
URL: ${file.url}`
}`,
);
});
})
.catch((error) => {
console.error(error);
});
I tried:
import { appFramework } from "wix-mobile";
import wixNavigateMobile from "wix-navigate-mobile";
let isProcessing = false;
export async function photoButton_onPress() {
if (isProcessing) return;
isProcessing = true;
try {
const files = await appFramework.showFileUploadPicker("Image", {
fileLimit: 1,
showCamera: true,
showDeviceMedia: true,
autoUpload: true,
});
const file = files?.\[0\];
if (!file?.url) {
throw new Error("The image could not be uploaded.");
}