-
Notifications
You must be signed in to change notification settings - Fork 1
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
Move uploaded references to Google Drive #123
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When files are uploaded to the Storage bucket path `independent-assessments/*`, a Cloud Function will move them into Google Drive. For now, the runtime variables at `src/moveIndependentAssessmentToGoogleDrive.js:10` are hardcoded. Eventually these will be driven by metadata that comes with the upload.
This commit refactors the functionality initially spiked in 6079a59. Files uploaded to the default Cloud Storage bucket, assuming a file path of: `references/{referenceId}/{fileName}`, are processed by the Cloud Function `processReferenceUpload`. The following steps are taken: - Find the associated reference in Firestore, given `{referenceId}` from the file upload path - If the reference is in state 'pending', upload the file to Google Drive. It'll be uploaded to the Team Drive denoted by `teamDriveId` (currently hardcoded in `functions/src/references/moveToGoogleDrive.js`), into the directory structure `{vacancyTitle}/{applicantName}/{assessorName} ({assessorType}).{ext}` - If the reference has already been marked as 'received', and this is therefore a duplicate upload, ignore the file and emit a log message. - Delete the file from Cloud Storage
Replace the hardcoded `teamDriveId` variable in `functions/src/references/moveToGoogleDrive.js` with Cloud Functions config. This is the variable used to determine which Google Team Drive to store received reference files in. Whilst this value doesn't need to be kept secret, it is configuration and so doesn't really belong in the codebase.
ollietreend
force-pushed
the
117-move-to-google-drive
branch
from
April 4, 2019 12:38
1719630
to
84a4317
Compare
tatyree
approved these changes
Apr 4, 2019
ollietreend
force-pushed
the
117-move-to-google-drive
branch
from
April 4, 2019 12:40
84a4317
to
b77617e
Compare
Update the npm packages used by Cloud Functions. Additionally, fix a linting error which seems to have cropped up with the upgrade of `eslint`.
ollietreend
force-pushed
the
117-move-to-google-drive
branch
from
April 4, 2019 12:41
b77617e
to
b67b737
Compare
This was referenced Aug 20, 2020
This was referenced Jun 10, 2021
6 tasks
3 tasks
This was referenced Feb 23, 2022
Closed
11 tasks
This was referenced May 23, 2022
3 tasks
3 tasks
This was referenced Jul 1, 2022
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #117
This PR adds a Cloud Function which is triggered when reference files are uploaded to the Cloud Storage bucket.
Files uploaded to the default Cloud Storage bucket, assuming a file path of:
references/{referenceId}/{fileName}
, are processed by the Cloud FunctionprocessReferenceUpload
.Steps taken when a new file is uploaded
{referenceId}
from the file upload pathreferences.team_drive_id
Functions config variable, into the directory structure{vacancyTitle}/{applicantName}/{assessorName} ({assessorType}).{ext}
Cloud Functions configuration
references.team_drive_id
Files are moved into the Google Team Drive with this ID.
This variable has already been set in production project.