Enable file upload form
Enable error boundary to catch React errors (#7) Fix warning for link noreferrer Include authorization header with file upload
This commit is contained in:
@@ -24,10 +24,10 @@ export const FileUploadProvider = ({ children }) => {
|
||||
done();
|
||||
};
|
||||
|
||||
const upload = async (files) => {
|
||||
const upload = async (files, accessToken) => {
|
||||
try {
|
||||
if (!files || files.length === 0) throw new Error("No file provided");
|
||||
|
||||
if (!files || files.length === 0) throw new Error("File required");
|
||||
if (!accessToken || accessToken.length === 0) throw new Error("Access token required")
|
||||
const file = files[0].file;
|
||||
const filename = file.name;
|
||||
|
||||
@@ -37,7 +37,7 @@ export const FileUploadProvider = ({ children }) => {
|
||||
setStatus(`Uploading ${filename}`);
|
||||
setCancelUpload(getCancelToken());
|
||||
|
||||
const { data } = await uploadFile(file, setProgress, cancelUpload);
|
||||
const { data } = await uploadFile(file, accessToken, setProgress, cancelUpload);
|
||||
if (data.message) throw new Error(`${data.error}. ${data.message}`);
|
||||
const url = ((data && data.link) ? data.link : "No URL available");
|
||||
setLinkURL(url);
|
||||
|
||||
Reference in New Issue
Block a user