Skip to content

Commit 15a84fb

Browse files
Dananjicjcolvar
authored andcommitted
Tweak for large file upload with S3
1 parent fd69be6 commit 15a84fb

File tree

5 files changed

+45
-3
lines changed

5 files changed

+45
-3
lines changed

app/helpers/upload_form_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@ def upload_form_data
4040
{}
4141
end
4242
end
43+
44+
# def multipart_upload_data
45+
# if direct_upload?
46+
# bucket = Aws::S3::Bucket.new(name: Settings.encoding.masterfile_bucket)
47+
# multipart_upload = Aws::S3::Client.new.create_multipart_upload(bucket: bucket.name, key: 'lo')
48+
# { 'upload_id' => multipart_upload[:upload_id] }
49+
# end
50+
# end
4351
end

app/javascript/components/FileUploadUppy.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Dashboard } from '@uppy/react';
44
import ActiveStorageUpload from '@excid3/uppy-activestorage-upload';
55
import GoogleDrive from '@uppy/google-drive';
66
import AwsS3 from '@uppy/aws-s3';
7+
import AwsS3Multipart from '@uppy/aws-s3-multipart';
78

89
require('@uppy/core/dist/style.css')
910
require('@uppy/dashboard/dist/style.css')
@@ -33,7 +34,14 @@ class FileUploadUppy extends React.Component {
3334
.use(GoogleDrive, {
3435
companionUrl: 'http://localhost:3020'
3536
})
37+
// .use(AwsS3Multipart, {
38+
// limit: 5,
39+
// timeout: 60*1000, // set to 1min
40+
// companionUrl: '/',
41+
// })
3642
.use(AwsS3, {
43+
limit: 5,
44+
timeout: 60*1000, // set to 1min
3745
companionUrl: 'http://localhost:3020',
3846
getUploadParameters() {
3947
return Promise.resolve({
@@ -69,9 +77,11 @@ class FileUploadUppy extends React.Component {
6977
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
7078
body: formData
7179
})
72-
.then(res => { })
80+
.then(res => {
81+
location.reload();
82+
})
7383
.catch(error => {
74-
console.error('MasterFile create failed, ', error);
84+
console.error('MasterFile creation failed, ', error);
7585
});
7686
}
7787
});

app/models/master_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def error
181181
# be set up in a configuration file somewhere
182182
#
183183
# 250 MB is the file limit for now
184-
MAXIMUM_UPLOAD_SIZE = Settings.max_upload_size || 2.gigabytes
184+
MAXIMUM_UPLOAD_SIZE = Settings.max_upload_size || 5.gigabytes
185185

186186
WORKFLOWS = ['fullaudio', 'avalon', 'pass_through', 'avalon-skip-transcoding', 'avalon-skip-transcoding-audio'].freeze
187187
AUDIO_TYPES = ["audio/vnd.wave", "audio/mpeg", "audio/mp3", "audio/mp4", "audio/wav", "audio/x-wav"]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@rails/webpacker": "^5.2.2",
88
"@samvera/iiif-react-media-player": "1.2.1",
99
"@uppy/aws-s3": "^3.0.4",
10+
"@uppy/aws-s3-multipart": "^3.1.1",
1011
"@uppy/companion": "^4.0.5",
1112
"@uppy/core": "^3.0.4",
1213
"@uppy/dashboard": "^3.1.0",

yarn.lock

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,14 @@
15121512
dependencies:
15131513
"@types/node" "*"
15141514

1515+
"@uppy/aws-s3-multipart@^3.1.1":
1516+
version "3.1.1"
1517+
resolved "https://registry.yarnpkg.com/@uppy/aws-s3-multipart/-/aws-s3-multipart-3.1.1.tgz#996184d7c73122d9a33b166e2960215e482e57ab"
1518+
integrity sha512-vL4QtbI5T4cGJLHm2GzKIGeaiy2zbgNW0nn/3LxYQ+wrBHLJoVZ/6uzMiFdNUBNa28rRQ/qxWTmy/kD6co95cg==
1519+
dependencies:
1520+
"@uppy/companion-client" "^3.1.1"
1521+
"@uppy/utils" "^5.1.1"
1522+
15151523
"@uppy/aws-s3@^3.0.4":
15161524
version "3.0.4"
15171525
resolved "https://registry.yarnpkg.com/@uppy/aws-s3/-/aws-s3-3.0.4.tgz#a2422a2091c57570ff99a77108296f09ba9e46a5"
@@ -1530,6 +1538,14 @@
15301538
"@uppy/utils" "^5.0.2"
15311539
namespace-emitter "^2.0.1"
15321540

1541+
"@uppy/companion-client@^3.1.1":
1542+
version "3.1.1"
1543+
resolved "https://registry.yarnpkg.com/@uppy/companion-client/-/companion-client-3.1.1.tgz#8c9974f70b899a40771da9a90113941356f9842e"
1544+
integrity sha512-S1M37vjWu8gdOgdI3Hh/1fVZ9GaLdyPQjVyUujZDTsr79b4VG7v/zjdqJ0FiOTjfGbpnj8s9kr1uyYi0Zf5VFw==
1545+
dependencies:
1546+
"@uppy/utils" "^5.1.1"
1547+
namespace-emitter "^2.0.1"
1548+
15331549
"@uppy/companion@^4.0.5":
15341550
version "4.0.5"
15351551
resolved "https://registry.yarnpkg.com/@uppy/companion/-/companion-4.0.5.tgz#ee448848fdd38d28747f6aec41eb365cb4143e3e"
@@ -1695,6 +1711,13 @@
16951711
dependencies:
16961712
lodash.throttle "^4.1.1"
16971713

1714+
"@uppy/utils@^5.1.1":
1715+
version "5.1.1"
1716+
resolved "https://registry.yarnpkg.com/@uppy/utils/-/utils-5.1.1.tgz#9597e8696e17d71413672bd56eb082c7410514a3"
1717+
integrity sha512-uoI+PcIVQboky0ZbN4PQeK1seZnnJocomzeK7blId9HKJ6QNgZLf2ibk2CQuQxrOuNsWhgrhs5uLO5Si0oM0Yw==
1718+
dependencies:
1719+
lodash.throttle "^4.1.1"
1720+
16981721
"@uppy/xhr-upload@^3.0.4":
16991722
version "3.0.4"
17001723
resolved "https://registry.yarnpkg.com/@uppy/xhr-upload/-/xhr-upload-3.0.4.tgz#219a92c832bee1f089992958d27ec71dbe9d9d7d"

0 commit comments

Comments
 (0)