Skip to content

Commit e8d6952

Browse files
committed
Tweak for large file upload with S3
1 parent de8d71c commit e8d6952

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
@@ -39,4 +39,12 @@ def upload_form_data
3939
{}
4040
end
4141
end
42+
43+
# def multipart_upload_data
44+
# if direct_upload?
45+
# bucket = Aws::S3::Bucket.new(name: Settings.encoding.masterfile_bucket)
46+
# multipart_upload = Aws::S3::Client.new.create_multipart_upload(bucket: bucket.name, key: 'lo')
47+
# { 'upload_id' => multipart_upload[:upload_id] }
48+
# end
49+
# end
4250
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
@@ -177,7 +177,7 @@ def error
177177
# be set up in a configuration file somewhere
178178
#
179179
# 250 MB is the file limit for now
180-
MAXIMUM_UPLOAD_SIZE = Settings.max_upload_size || 2.gigabytes
180+
MAXIMUM_UPLOAD_SIZE = Settings.max_upload_size || 5.gigabytes
181181

182182
WORKFLOWS = ['fullaudio', 'avalon', 'pass_through', 'avalon-skip-transcoding', 'avalon-skip-transcoding-audio'].freeze
183183
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
@@ -1507,6 +1507,14 @@
15071507
dependencies:
15081508
"@types/node" "*"
15091509

1510+
"@uppy/aws-s3-multipart@^3.1.1":
1511+
version "3.1.1"
1512+
resolved "https://registry.yarnpkg.com/@uppy/aws-s3-multipart/-/aws-s3-multipart-3.1.1.tgz#996184d7c73122d9a33b166e2960215e482e57ab"
1513+
integrity sha512-vL4QtbI5T4cGJLHm2GzKIGeaiy2zbgNW0nn/3LxYQ+wrBHLJoVZ/6uzMiFdNUBNa28rRQ/qxWTmy/kD6co95cg==
1514+
dependencies:
1515+
"@uppy/companion-client" "^3.1.1"
1516+
"@uppy/utils" "^5.1.1"
1517+
15101518
"@uppy/aws-s3@^3.0.4":
15111519
version "3.0.4"
15121520
resolved "https://registry.yarnpkg.com/@uppy/aws-s3/-/aws-s3-3.0.4.tgz#a2422a2091c57570ff99a77108296f09ba9e46a5"
@@ -1525,6 +1533,14 @@
15251533
"@uppy/utils" "^5.0.2"
15261534
namespace-emitter "^2.0.1"
15271535

1536+
"@uppy/companion-client@^3.1.1":
1537+
version "3.1.1"
1538+
resolved "https://registry.yarnpkg.com/@uppy/companion-client/-/companion-client-3.1.1.tgz#8c9974f70b899a40771da9a90113941356f9842e"
1539+
integrity sha512-S1M37vjWu8gdOgdI3Hh/1fVZ9GaLdyPQjVyUujZDTsr79b4VG7v/zjdqJ0FiOTjfGbpnj8s9kr1uyYi0Zf5VFw==
1540+
dependencies:
1541+
"@uppy/utils" "^5.1.1"
1542+
namespace-emitter "^2.0.1"
1543+
15281544
"@uppy/companion@^4.0.5":
15291545
version "4.0.5"
15301546
resolved "https://registry.yarnpkg.com/@uppy/companion/-/companion-4.0.5.tgz#ee448848fdd38d28747f6aec41eb365cb4143e3e"
@@ -1690,6 +1706,13 @@
16901706
dependencies:
16911707
lodash.throttle "^4.1.1"
16921708

1709+
"@uppy/utils@^5.1.1":
1710+
version "5.1.1"
1711+
resolved "https://registry.yarnpkg.com/@uppy/utils/-/utils-5.1.1.tgz#9597e8696e17d71413672bd56eb082c7410514a3"
1712+
integrity sha512-uoI+PcIVQboky0ZbN4PQeK1seZnnJocomzeK7blId9HKJ6QNgZLf2ibk2CQuQxrOuNsWhgrhs5uLO5Si0oM0Yw==
1713+
dependencies:
1714+
lodash.throttle "^4.1.1"
1715+
16931716
"@uppy/xhr-upload@^3.0.4":
16941717
version "3.0.4"
16951718
resolved "https://registry.yarnpkg.com/@uppy/xhr-upload/-/xhr-upload-3.0.4.tgz#219a92c832bee1f089992958d27ec71dbe9d9d7d"

0 commit comments

Comments
 (0)