-
Notifications
You must be signed in to change notification settings - Fork 306
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
Rs hotfix/fix corrupt image uploads #7781
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,9 @@ const headers = { | |
|
||
function uploadImage() { | ||
return gulp | ||
.src("content/uploads/_working-images/processed/*") | ||
.src("content/uploads/_working-images/processed/*", { | ||
encoding: false, | ||
}) | ||
.pipe(publisher.publish(headers)) | ||
.pipe( | ||
awspublish.reporter({ | ||
|
@@ -44,7 +46,9 @@ function uploadFile() { | |
}); | ||
|
||
return gulp | ||
.src("content/uploads/_working-files/to-process/*") | ||
.src("content/uploads/_working-files/to-process/*", { | ||
removeBOM: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note We'll have to test slides and/or spreadsheet for this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you log in to S3 you will see the PowerPoints I was using to test. Have not deleted them yet. I tested personally,
|
||
}) | ||
.pipe(staticRename) | ||
.pipe(publisher.publish(headers)) | ||
.pipe( | ||
|
@@ -61,20 +65,18 @@ function uploadFile() { | |
function cleanup() { | ||
return new Promise((resolve, reject) => { | ||
let imageDir = "content/uploads/_working-images/processed"; | ||
let fileDir = "content/uploads/_working-files/to-process"; | ||
let fileDir = "content/uploads/_working-files"; | ||
|
||
if (fs.existsSync(imageDir)) { | ||
if (fs.readdirSync(imageDir).length > 0) { | ||
console.log(`Images have number of files ${fs.readdirSync(imageDir).length}`); | ||
// delete tht folder | ||
del([imageDir]); | ||
resolve(); | ||
} else { | ||
resolve(); | ||
} | ||
} else { | ||
resolve(); | ||
// remove the folder | ||
del([imageDir]); | ||
} | ||
|
||
if (fs.existsSync(fileDir)) { | ||
// remove the folder | ||
del([fileDir]); | ||
} | ||
resolve(); | ||
}); | ||
} | ||
|
||
|
@@ -114,33 +116,19 @@ function determineWhichToUpload() { | |
|
||
if (imageFiles.length > 0) { | ||
uploadsToComplete += 1; | ||
const imageUploadStream = uploadImage(); | ||
imageUploadStream.on('finish', () => { | ||
uploadsCompleted += 1; | ||
checkCompletion(); | ||
}); | ||
imageUploadStream.on('error', (err) => { | ||
console.error("Error uploading images:", err); | ||
reject(err); | ||
}); | ||
uploadImage(); | ||
uploadsCompleted += 1; | ||
checkCompletion(); | ||
} | ||
|
||
if (fileFiles.length > 0) { | ||
uploadsToComplete += 1; | ||
const fileUploadStream = uploadFile(); | ||
fileUploadStream.on('finish', () => { | ||
uploadsCompleted += 1; | ||
checkCompletion(); | ||
}); | ||
fileUploadStream.on('error', (err) => { | ||
console.error("Error uploading files:", err); | ||
reject(err); | ||
}); | ||
uploadFile(); | ||
uploadsCompleted += 1; | ||
checkCompletion(); | ||
} | ||
|
||
if (uploadsToComplete === 0) { | ||
resolve(); // If no uploads are initiated, resolve immediately. | ||
} | ||
return resolve(); | ||
}); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How I tested:
content/uploads/_inbox
npx gulp upload
for each file type listed belowstatic files are uploaded, accessible on aws but the file is corrupt. Test files are located at
static/test-upload-7-12-2024.*
image files, both
png
andjpg
are not found:Note
I removed the
file.upload.do
from thegulpfile.js
and can confirm that thecontent/uploads/_working-images/processed/
is created.digitalgov.gov/gulpfile.js
Line 40 in 4375f5f
I don't see those folders when I use the new code changes:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nick-mon1 very strange, when I run upload on a .xlsx file I see this
It opens as spreadsheet as well at this link
https://s3.amazonaws.com/digitalgov/static/test-sheet-riley-v1.xlsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming you're testing all the files uploading at once. I'll do that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RileySeaburg I tested each file one at a time, did not try all of them at once since they won't typically happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird.
I'm stepping off the happy path and am going to debug a multiple upload scenario.
That's where I'm able to get errors.