2024-01-20 16:16:14 +00:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
import React, { useState, createContext, useContext, useEffect } from 'react';
|
|
|
|
import Uppy from '@uppy/core';
|
|
|
|
import AwsS3 from '@uppy/aws-s3';
|
|
|
|
import RemoteSources from '@uppy/remote-sources';
|
2024-11-05 19:48:21 +00:00
|
|
|
// import { useAuth } from './components/auth';
|
2024-07-10 22:11:18 +00:00
|
|
|
import { companionUrl } from '@/app/lib/constants';
|
2024-01-20 16:16:14 +00:00
|
|
|
|
|
|
|
|
2024-07-06 08:49:51 +00:00
|
|
|
// Uppy is a challenging react integration. Following are some references
|
|
|
|
// @see https://github.com/transloadit/uppy/issues/4727#issuecomment-1761118428
|
|
|
|
|
|
|
|
|
2024-01-20 16:16:14 +00:00
|
|
|
export const UppyContext = createContext(new Uppy());
|
|
|
|
|
2024-11-05 19:48:21 +00:00
|
|
|
// export default function UppyProvider({
|
|
|
|
// children
|
|
|
|
// }: {
|
|
|
|
// children: React.ReactNode
|
|
|
|
// }) {
|
|
|
|
// // const { authData } = useAuth();
|
|
|
|
// const uppy = new Uppy(
|
|
|
|
// // const [uppy] = useState(() => new Uppy(
|
|
|
|
// {
|
|
|
|
// autoProceed: true,
|
|
|
|
// debug: true,
|
|
|
|
// logger: {
|
|
|
|
// debug: console.info,
|
|
|
|
// warn: console.log,
|
|
|
|
// error: console.error
|
|
|
|
// },
|
|
|
|
|
|
|
|
// }
|
|
|
|
// )
|
|
|
|
// .use(RemoteSources, {
|
|
|
|
// companionUrl,
|
|
|
|
// title: 'testing 123',
|
|
|
|
// })
|
|
|
|
// .use(AwsS3, {
|
|
|
|
// companionUrl,
|
|
|
|
// shouldUseMultipart: true,
|
|
|
|
// abortMultipartUpload: () => {}, // @see https://github.com/transloadit/uppy/issues/1197#issuecomment-491756118
|
|
|
|
// companionHeaders: {
|
|
|
|
// 'authorization': `Bearer ${authData?.accessToken}`
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// // );
|
2024-01-20 16:16:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-05 19:48:21 +00:00
|
|
|
// return (
|
|
|
|
// <UppyContext.Provider value={uppy}>
|
|
|
|
// {children}
|
|
|
|
// </UppyContext.Provider>
|
|
|
|
// )
|
|
|
|
// }
|