feat: translodit
This commit is contained in:
parent
30396f6a35
commit
2c4d0a8234
|
|
@ -122,11 +122,12 @@ export function useUppyUploader(props: {
|
|||
});
|
||||
|
||||
const { plugin, options } = getUppyUploadPlugin(
|
||||
storageProvider,
|
||||
transloadit.length > 0 ? 'transloadit' : storageProvider,
|
||||
fetch,
|
||||
backendUrl,
|
||||
transloadit
|
||||
);
|
||||
|
||||
uppy2.use(plugin, options);
|
||||
if (!disableImageCompression) {
|
||||
uppy2.use(Compressor, {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import XHRUpload from '@uppy/xhr-upload';
|
||||
import AwsS3Multipart from '@uppy/aws-s3';
|
||||
import sha256 from 'sha256';
|
||||
import Transloadit from '@uppy/transloadit';
|
||||
const fetchUploadApiEndpoint = async (
|
||||
fetch: any,
|
||||
endpoint: string,
|
||||
|
|
@ -22,10 +23,21 @@ export const getUppyUploadPlugin = (
|
|||
provider: string,
|
||||
fetch: any,
|
||||
backendUrl: string,
|
||||
transloadit: string[] = [],
|
||||
isVideo: boolean = false,
|
||||
transloadit: string[] = []
|
||||
) => {
|
||||
switch (provider) {
|
||||
case 'transloadit':
|
||||
return {
|
||||
plugin: Transloadit,
|
||||
options: {
|
||||
assemblyOptions: {
|
||||
params: {
|
||||
auth: { key: transloadit[0] },
|
||||
template_id: transloadit[1],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
case 'cloudflare':
|
||||
return {
|
||||
plugin: AwsS3Multipart,
|
||||
|
|
@ -35,18 +47,21 @@ export const getUppyUploadPlugin = (
|
|||
createMultipartUpload: async (file: any) => {
|
||||
let fileHash = '';
|
||||
const contentType = file.type;
|
||||
|
||||
|
||||
// Skip hash calculation for files larger than 100MB to avoid "Invalid array length" error
|
||||
if (file.size <= 100 * 1024 * 1024) {
|
||||
try {
|
||||
const arrayBuffer = await new Response(file.data).arrayBuffer();
|
||||
fileHash = sha256(Buffer.from(arrayBuffer));
|
||||
} catch (error) {
|
||||
console.warn('Failed to calculate file hash, proceeding without hash:', error);
|
||||
console.warn(
|
||||
'Failed to calculate file hash, proceeding without hash:',
|
||||
error
|
||||
);
|
||||
fileHash = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return fetchUploadApiEndpoint(fetch, 'create-multipart-upload', {
|
||||
file,
|
||||
fileHash,
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@
|
|||
"@uppy/progress-bar": "^4.0.0",
|
||||
"@uppy/react": "^4.0.2",
|
||||
"@uppy/status-bar": "^4.0.3",
|
||||
"@uppy/transloadit": "^4.2.2",
|
||||
"@uppy/xhr-upload": "^4.1.0",
|
||||
"accept-language": "^3.0.20",
|
||||
"ai": "^4.0.22",
|
||||
|
|
|
|||
122
pnpm-lock.yaml
122
pnpm-lock.yaml
|
|
@ -228,6 +228,9 @@ importers:
|
|||
'@uppy/status-bar':
|
||||
specifier: ^4.0.3
|
||||
version: 4.1.3(@uppy/core@4.4.4)
|
||||
'@uppy/transloadit':
|
||||
specifier: ^4.2.2
|
||||
version: 4.2.2(@uppy/core@4.4.4)
|
||||
'@uppy/xhr-upload':
|
||||
specifier: ^4.1.0
|
||||
version: 4.3.3(@uppy/core@4.4.4)
|
||||
|
|
@ -6463,6 +6466,16 @@ packages:
|
|||
peerDependencies:
|
||||
'@uppy/core': ^4.4.1
|
||||
|
||||
'@uppy/transloadit@4.2.2':
|
||||
resolution: {integrity: sha512-R7iKDi3gbbcZydUulSLIwCAI5krPTZBUfWIBkdc4XpcL5oGQHHjLmVbSIyLgsTBrBowrtaQP2Nj6ZkWtF6LF+Q==}
|
||||
peerDependencies:
|
||||
'@uppy/core': ^4.4.4
|
||||
|
||||
'@uppy/tus@4.2.2':
|
||||
resolution: {integrity: sha512-fauUHqoLDtyRXwoaIyWM8ctuJ+SAXdjuM2eyoPYcGtpVaEGa+AS7IQkJkWz2RrWSdLCHL9O+fk6jKr+0PIDEpQ==}
|
||||
peerDependencies:
|
||||
'@uppy/core': ^4.4.1
|
||||
|
||||
'@uppy/utils@6.1.3':
|
||||
resolution: {integrity: sha512-7WuTtMf0k1g962sE76mKy8aDV/kLeDrF8Wv1oTxaXQzUpmHBAoKd3FXLrQXu7TgM0XNHHRZXAckBttbVOWkKCw==}
|
||||
|
||||
|
|
@ -7701,6 +7714,9 @@ packages:
|
|||
resolution: {integrity: sha512-lomjuFZKfM6MSAnV9aCZC9sc0qGbmZdfygNv+nCpqVkSKdCxCklLtd16O0EILGkImHw9ZpHkAnHaB+8Zxq5W6Q==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
combine-errors@3.0.3:
|
||||
resolution: {integrity: sha512-C8ikRNRMygCwaTx+Ek3Yr+OuZzgZjduCOfSQBjbM8V3MfgcjSTeto/GXP6PAwKvJz/v15b7GHZvx5rOlczFw/Q==}
|
||||
|
||||
combined-stream@1.0.8:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
|
@ -7748,6 +7764,10 @@ packages:
|
|||
compare-versions@4.1.4:
|
||||
resolution: {integrity: sha512-FemMreK9xNyL8gQevsdRMrvO4lFCkQP7qbuktn1q8ndcNk1+0mz7lgE7b/sNvbhVgY4w6tMN1FDp6aADjqw2rw==}
|
||||
|
||||
component-emitter@2.0.0:
|
||||
resolution: {integrity: sha512-4m5s3Me2xxlVKG9PkZpQqHQR7bgpnN7joDMJ4yvVkVXngjoITG76IaZmzmywSeRTeTpc6N6r3H3+KyUurV8OYw==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
compressible@2.0.18:
|
||||
resolution: {integrity: sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
|
@ -8098,6 +8118,9 @@ packages:
|
|||
currency-codes@1.5.1:
|
||||
resolution: {integrity: sha512-hqy8vtlIYKzO6pe2TE0V4/riZALIc7nhtE9cvxk5FDRCvfGplgzUvpTmZlMsyO+NeK5U41j+sQXJOo8l8v9kdg==}
|
||||
|
||||
custom-error-instance@2.1.1:
|
||||
resolution: {integrity: sha512-p6JFxJc3M4OTD2li2qaHkDCw9SfMw82Ldr6OC9Je1aXiGfhx2W8p3GaoeaGrPJTUN9NirTM/KTxHWMUdR1rsUg==}
|
||||
|
||||
damerau-levenshtein@1.0.8:
|
||||
resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}
|
||||
|
||||
|
|
@ -11013,6 +11036,24 @@ packages:
|
|||
lodash-es@4.17.21:
|
||||
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
|
||||
|
||||
lodash._baseiteratee@4.7.0:
|
||||
resolution: {integrity: sha512-nqB9M+wITz0BX/Q2xg6fQ8mLkyfF7MU7eE+MNBNjTHFKeKaZAPEzEg+E8LWxKWf1DQVflNEn9N49yAuqKh2mWQ==}
|
||||
|
||||
lodash._basetostring@4.12.0:
|
||||
resolution: {integrity: sha512-SwcRIbyxnN6CFEEK4K1y+zuApvWdpQdBHM/swxP962s8HIxPO3alBH5t3m/dl+f4CMUug6sJb7Pww8d13/9WSw==}
|
||||
|
||||
lodash._baseuniq@4.6.0:
|
||||
resolution: {integrity: sha512-Ja1YevpHZctlI5beLA7oc5KNDhGcPixFhcqSiORHNsp/1QTv7amAXzw+gu4YOvErqVlMVyIJGgtzeepCnnur0A==}
|
||||
|
||||
lodash._createset@4.0.3:
|
||||
resolution: {integrity: sha512-GTkC6YMprrJZCYU3zcqZj+jkXkrXzq3IPBcF/fIPpNEAB4hZEtXU8zp/RwKOvZl43NUmwDbyRk3+ZTbeRdEBXA==}
|
||||
|
||||
lodash._root@3.0.1:
|
||||
resolution: {integrity: sha512-O0pWuFSK6x4EXhM1dhZ8gchNtG7JMqBtrHdoUFUWXD7dJnNSUze1GuyQr5sOs0aCvgGeI3o/OJW8f4ca7FDxmQ==}
|
||||
|
||||
lodash._stringtopath@4.8.0:
|
||||
resolution: {integrity: sha512-SXL66C731p0xPDC5LZg4wI5H+dJo/EO4KTqOMwLYCH3+FmmfAKJEZCm6ohGpI+T1xwsDsJCfL4OnhorllvlTPQ==}
|
||||
|
||||
lodash.clonedeepwith@4.5.0:
|
||||
resolution: {integrity: sha512-QRBRSxhbtsX1nc0baxSkkK5WlVTTm/s48DSukcGcWZwIyI8Zz+lB+kFiELJXtzfH4Aj6kMWQ1VWW4U5uUDgZMA==}
|
||||
|
||||
|
|
@ -11072,6 +11113,9 @@ packages:
|
|||
lodash.uniq@4.5.0:
|
||||
resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==}
|
||||
|
||||
lodash.uniqby@4.5.0:
|
||||
resolution: {integrity: sha512-IRt7cfTtHy6f1aRVA5n7kT8rgN3N1nH6MOWLcHfpWG2SH19E3JksLK38MktLxZDhlAjCP9jpIXkOnRXlu6oByQ==}
|
||||
|
||||
lodash@4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
|
||||
|
|
@ -12867,6 +12911,9 @@ packages:
|
|||
prop-types@15.8.1:
|
||||
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
||||
|
||||
proper-lockfile@4.1.2:
|
||||
resolution: {integrity: sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==}
|
||||
|
||||
property-expr@2.0.6:
|
||||
resolution: {integrity: sha512-SVtmxhRE/CGkn3eZY1T6pC8Nln6Fr/lu1mKSgRud0eC73whjGfoAogbn78LkD8aFL0zz3bAFerKSnOl7NlErBA==}
|
||||
|
||||
|
|
@ -13566,6 +13613,10 @@ packages:
|
|||
peerDependencies:
|
||||
axios: '*'
|
||||
|
||||
retry@0.12.0:
|
||||
resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==}
|
||||
engines: {node: '>= 4'}
|
||||
|
||||
retry@0.13.1:
|
||||
resolution: {integrity: sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==}
|
||||
engines: {node: '>= 4'}
|
||||
|
|
@ -14727,6 +14778,10 @@ packages:
|
|||
tunnel-agent@0.6.0:
|
||||
resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
|
||||
|
||||
tus-js-client@4.3.1:
|
||||
resolution: {integrity: sha512-ZLeYmjrkaU1fUsKbIi8JML52uAocjEZtBx4DKjRrqzrZa0O4MYwT6db+oqePlspV+FxXJAyFBc/L5gwUi2OFsg==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
tweetnacl@0.14.5:
|
||||
resolution: {integrity: sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==}
|
||||
|
||||
|
|
@ -23550,6 +23605,22 @@ snapshots:
|
|||
'@uppy/utils': 6.1.3
|
||||
exifr: 7.1.3
|
||||
|
||||
'@uppy/transloadit@4.2.2(@uppy/core@4.4.4)':
|
||||
dependencies:
|
||||
'@uppy/companion-client': 4.4.1(@uppy/core@4.4.4)
|
||||
'@uppy/core': 4.4.4
|
||||
'@uppy/provider-views': 4.4.3(@uppy/core@4.4.4)
|
||||
'@uppy/tus': 4.2.2(@uppy/core@4.4.4)
|
||||
'@uppy/utils': 6.1.3
|
||||
component-emitter: 2.0.0
|
||||
|
||||
'@uppy/tus@4.2.2(@uppy/core@4.4.4)':
|
||||
dependencies:
|
||||
'@uppy/companion-client': 4.4.1(@uppy/core@4.4.4)
|
||||
'@uppy/core': 4.4.4
|
||||
'@uppy/utils': 6.1.3
|
||||
tus-js-client: 4.3.1
|
||||
|
||||
'@uppy/utils@6.1.3':
|
||||
dependencies:
|
||||
lodash: 4.17.21
|
||||
|
|
@ -25490,6 +25561,11 @@ snapshots:
|
|||
strip-ansi: 6.0.1
|
||||
wcwidth: 1.0.1
|
||||
|
||||
combine-errors@3.0.3:
|
||||
dependencies:
|
||||
custom-error-instance: 2.1.1
|
||||
lodash.uniqby: 4.5.0
|
||||
|
||||
combined-stream@1.0.8:
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
|
|
@ -25524,6 +25600,8 @@ snapshots:
|
|||
|
||||
compare-versions@4.1.4: {}
|
||||
|
||||
component-emitter@2.0.0: {}
|
||||
|
||||
compressible@2.0.18:
|
||||
dependencies:
|
||||
mime-db: 1.54.0
|
||||
|
|
@ -25947,6 +26025,8 @@ snapshots:
|
|||
first-match: 0.0.1
|
||||
nub: 0.0.0
|
||||
|
||||
custom-error-instance@2.1.1: {}
|
||||
|
||||
damerau-levenshtein@1.0.8: {}
|
||||
|
||||
dashdash@1.14.1:
|
||||
|
|
@ -29726,6 +29806,25 @@ snapshots:
|
|||
|
||||
lodash-es@4.17.21: {}
|
||||
|
||||
lodash._baseiteratee@4.7.0:
|
||||
dependencies:
|
||||
lodash._stringtopath: 4.8.0
|
||||
|
||||
lodash._basetostring@4.12.0: {}
|
||||
|
||||
lodash._baseuniq@4.6.0:
|
||||
dependencies:
|
||||
lodash._createset: 4.0.3
|
||||
lodash._root: 3.0.1
|
||||
|
||||
lodash._createset@4.0.3: {}
|
||||
|
||||
lodash._root@3.0.1: {}
|
||||
|
||||
lodash._stringtopath@4.8.0:
|
||||
dependencies:
|
||||
lodash._basetostring: 4.12.0
|
||||
|
||||
lodash.clonedeepwith@4.5.0: {}
|
||||
|
||||
lodash.compact@3.0.1: {}
|
||||
|
|
@ -29764,6 +29863,11 @@ snapshots:
|
|||
|
||||
lodash.uniq@4.5.0: {}
|
||||
|
||||
lodash.uniqby@4.5.0:
|
||||
dependencies:
|
||||
lodash._baseiteratee: 4.7.0
|
||||
lodash._baseuniq: 4.6.0
|
||||
|
||||
lodash@4.17.21: {}
|
||||
|
||||
log-symbols@4.1.0:
|
||||
|
|
@ -32163,6 +32267,12 @@ snapshots:
|
|||
object-assign: 4.1.1
|
||||
react-is: 16.13.1
|
||||
|
||||
proper-lockfile@4.1.2:
|
||||
dependencies:
|
||||
graceful-fs: 4.2.11
|
||||
retry: 0.12.0
|
||||
signal-exit: 3.0.7
|
||||
|
||||
property-expr@2.0.6: {}
|
||||
|
||||
property-information@5.6.0:
|
||||
|
|
@ -33074,6 +33184,8 @@ snapshots:
|
|||
dependencies:
|
||||
axios: 1.9.0(debug@4.4.0)
|
||||
|
||||
retry@0.12.0: {}
|
||||
|
||||
retry@0.13.1: {}
|
||||
|
||||
reusify@1.1.0: {}
|
||||
|
|
@ -34411,6 +34523,16 @@ snapshots:
|
|||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
tus-js-client@4.3.1:
|
||||
dependencies:
|
||||
buffer-from: 1.1.2
|
||||
combine-errors: 3.0.3
|
||||
is-stream: 2.0.1
|
||||
js-base64: 3.7.7
|
||||
lodash.throttle: 4.1.1
|
||||
proper-lockfile: 4.1.2
|
||||
url-parse: 1.5.10
|
||||
|
||||
tweetnacl@0.14.5: {}
|
||||
|
||||
tweetnacl@1.0.3: {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue