Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for multi-service direct uploads #43650

Merged
merged 2 commits into from Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion actiontext/app/javascript/actiontext/attachment_upload.js
Expand Up @@ -4,7 +4,7 @@ export class AttachmentUpload {
constructor(attachment, element) {
this.attachment = attachment
this.element = element
this.directUpload = new DirectUpload(attachment.file, this.directUploadUrl, this)
this.directUpload = new DirectUpload(attachment.file, this.directUploadUrl, this.directUploadToken, this.attachmentName, this)
}

start() {
Expand Down Expand Up @@ -42,4 +42,11 @@ export class AttachmentUpload {
get blobUrlTemplate() {
return this.element.dataset.blobUrlTemplate
}

get directUploadToken() {
return this.element.getAttribute("data-direct-upload-token");
}
get attachmentName() {
return this.element.getAttribute("data-direct-upload-attachment-name");
}
}
Expand Up @@ -25,7 +25,7 @@ class ActiveStorage::S3DirectUploadsControllerTest < ActionDispatch::Integration
"library_ID": "12345"
}

ActiveStorage::DirectUploadToken.stub(:verify_direct_upload_token, "local") do
ActiveStorage::DirectUploadToken.stub(:verify_direct_upload_token, "s3") do
post rails_direct_uploads_url, params: { blob: {
filename: "hello.txt", byte_size: 6, checksum: checksum, content_type: "text/plain", metadata: metadata } }
end
Expand Down Expand Up @@ -70,7 +70,7 @@ class ActiveStorage::GCSDirectUploadsControllerTest < ActionDispatch::Integratio
"library_ID": "12345"
}

ActiveStorage::DirectUploadToken.stub(:verify_direct_upload_token, "local") do
ActiveStorage::DirectUploadToken.stub(:verify_direct_upload_token, "gcs") do
post rails_direct_uploads_url, params: { blob: {
filename: "hello.txt", byte_size: 6, checksum: checksum, content_type: "text/plain", metadata: metadata } }
end
Expand Down Expand Up @@ -114,7 +114,7 @@ class ActiveStorage::AzureStorageDirectUploadsControllerTest < ActionDispatch::I
"library_ID": "12345"
}

ActiveStorage::DirectUploadToken.stub(:verify_direct_upload_token, "local") do
ActiveStorage::DirectUploadToken.stub(:verify_direct_upload_token, "azure") do
post rails_direct_uploads_url, params: { blob: {
filename: "hello.txt", byte_size: 6, checksum: checksum, content_type: "text/plain", metadata: metadata } }
end
Expand Down