Skip to content

Commit

Permalink
To resolve CORS error
Browse files Browse the repository at this point in the history
  • Loading branch information
JayanthyChengan committed Nov 1, 2023
1 parent bfa4756 commit c90aa75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,8 @@ private String generateTemporaryS3UploadUrl(String key, Date expiration) throws
GeneratePresignedUrlRequest generatePresignedUrlRequest =
new GeneratePresignedUrlRequest(bucketName, key).withMethod(HttpMethod.PUT).withExpiration(expiration);
//Require user to add this header to indicate a temporary file
generatePresignedUrlRequest.putCustomRequestHeader(Headers.S3_TAGGING, "dv-state=temp");
// JC commented the below line due to CORS issue
//generatePresignedUrlRequest.putCustomRequestHeader(Headers.S3_TAGGING, "dv-state=temp");

URL presignedUrl;
try {
Expand Down Expand Up @@ -1037,7 +1038,8 @@ public JsonObjectBuilder generateTemporaryS3UploadUrls(String globalId, String s
} else {
JsonObjectBuilder urls = Json.createObjectBuilder();
InitiateMultipartUploadRequest initiationRequest = new InitiateMultipartUploadRequest(bucketName, key);
initiationRequest.putCustomRequestHeader(Headers.S3_TAGGING, "dv-state=temp");
// JC commented the below line due to CORS issue
// initiationRequest.putCustomRequestHeader(Headers.S3_TAGGING, "dv-state=temp");
InitiateMultipartUploadResult initiationResponse = s3.initiateMultipartUpload(initiationRequest);
String uploadId = initiationResponse.getUploadId();
for (int i = 1; i <= (fileSize / minPartSize) + (fileSize % minPartSize > 0 ? 1 : 0); i++) {
Expand Down
1 change: 0 additions & 1 deletion src/main/webapp/resources/js/fileupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ var fileUpload = class fileUploadClass {
if(this.urls.hasOwnProperty("url")) {
$.ajax({
url: this.urls.url,
headers: { "x-amz-tagging": "dv-state=temp" },
type: 'PUT',
data: this.file,
context:this,
Expand Down

0 comments on commit c90aa75

Please sign in to comment.