Skip to content

Commit

Permalink
Tweak for large file upload with S3
Browse files Browse the repository at this point in the history
  • Loading branch information
Dananji authored and cjcolvar committed Aug 7, 2023
1 parent fd69be6 commit 15a84fb
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/helpers/upload_form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@ def upload_form_data
{}
end
end

# def multipart_upload_data
# if direct_upload?
# bucket = Aws::S3::Bucket.new(name: Settings.encoding.masterfile_bucket)
# multipart_upload = Aws::S3::Client.new.create_multipart_upload(bucket: bucket.name, key: 'lo')
# { 'upload_id' => multipart_upload[:upload_id] }
# end
# end
end
14 changes: 12 additions & 2 deletions app/javascript/components/FileUploadUppy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Dashboard } from '@uppy/react';
import ActiveStorageUpload from '@excid3/uppy-activestorage-upload';
import GoogleDrive from '@uppy/google-drive';
import AwsS3 from '@uppy/aws-s3';
import AwsS3Multipart from '@uppy/aws-s3-multipart';

require('@uppy/core/dist/style.css')
require('@uppy/dashboard/dist/style.css')
Expand Down Expand Up @@ -33,7 +34,14 @@ class FileUploadUppy extends React.Component {
.use(GoogleDrive, {
companionUrl: 'http://localhost:3020'
})
// .use(AwsS3Multipart, {
// limit: 5,
// timeout: 60*1000, // set to 1min
// companionUrl: '/',
// })
.use(AwsS3, {
limit: 5,
timeout: 60*1000, // set to 1min
companionUrl: 'http://localhost:3020',
getUploadParameters() {
return Promise.resolve({
Expand Down Expand Up @@ -69,9 +77,11 @@ class FileUploadUppy extends React.Component {
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
body: formData
})
.then(res => { })
.then(res => {
location.reload();
})
.catch(error => {
console.error('MasterFile create failed, ', error);
console.error('MasterFile creation failed, ', error);
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion app/models/master_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def error
# be set up in a configuration file somewhere
#
# 250 MB is the file limit for now
MAXIMUM_UPLOAD_SIZE = Settings.max_upload_size || 2.gigabytes
MAXIMUM_UPLOAD_SIZE = Settings.max_upload_size || 5.gigabytes

WORKFLOWS = ['fullaudio', 'avalon', 'pass_through', 'avalon-skip-transcoding', 'avalon-skip-transcoding-audio'].freeze
AUDIO_TYPES = ["audio/vnd.wave", "audio/mpeg", "audio/mp3", "audio/mp4", "audio/wav", "audio/x-wav"]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@rails/webpacker": "^5.2.2",
"@samvera/iiif-react-media-player": "1.2.1",
"@uppy/aws-s3": "^3.0.4",
"@uppy/aws-s3-multipart": "^3.1.1",
"@uppy/companion": "^4.0.5",
"@uppy/core": "^3.0.4",
"@uppy/dashboard": "^3.1.0",
Expand Down
23 changes: 23 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,14 @@
dependencies:
"@types/node" "*"

"@uppy/aws-s3-multipart@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@uppy/aws-s3-multipart/-/aws-s3-multipart-3.1.1.tgz#996184d7c73122d9a33b166e2960215e482e57ab"
integrity sha512-vL4QtbI5T4cGJLHm2GzKIGeaiy2zbgNW0nn/3LxYQ+wrBHLJoVZ/6uzMiFdNUBNa28rRQ/qxWTmy/kD6co95cg==
dependencies:
"@uppy/companion-client" "^3.1.1"
"@uppy/utils" "^5.1.1"

"@uppy/aws-s3@^3.0.4":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@uppy/aws-s3/-/aws-s3-3.0.4.tgz#a2422a2091c57570ff99a77108296f09ba9e46a5"
Expand All @@ -1530,6 +1538,14 @@
"@uppy/utils" "^5.0.2"
namespace-emitter "^2.0.1"

"@uppy/companion-client@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@uppy/companion-client/-/companion-client-3.1.1.tgz#8c9974f70b899a40771da9a90113941356f9842e"
integrity sha512-S1M37vjWu8gdOgdI3Hh/1fVZ9GaLdyPQjVyUujZDTsr79b4VG7v/zjdqJ0FiOTjfGbpnj8s9kr1uyYi0Zf5VFw==
dependencies:
"@uppy/utils" "^5.1.1"
namespace-emitter "^2.0.1"

"@uppy/companion@^4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@uppy/companion/-/companion-4.0.5.tgz#ee448848fdd38d28747f6aec41eb365cb4143e3e"
Expand Down Expand Up @@ -1695,6 +1711,13 @@
dependencies:
lodash.throttle "^4.1.1"

"@uppy/utils@^5.1.1":
version "5.1.1"
resolved "https://registry.yarnpkg.com/@uppy/utils/-/utils-5.1.1.tgz#9597e8696e17d71413672bd56eb082c7410514a3"
integrity sha512-uoI+PcIVQboky0ZbN4PQeK1seZnnJocomzeK7blId9HKJ6QNgZLf2ibk2CQuQxrOuNsWhgrhs5uLO5Si0oM0Yw==
dependencies:
lodash.throttle "^4.1.1"

"@uppy/xhr-upload@^3.0.4":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@uppy/xhr-upload/-/xhr-upload-3.0.4.tgz#219a92c832bee1f089992958d27ec71dbe9d9d7d"
Expand Down

0 comments on commit 15a84fb

Please sign in to comment.