Comments (3)
I created two functions and uploaded them to branch feature/79-upload-file-via-hasura-to-a-storage-bucket
- an Action(Mutation) to upload a file "saveFile".
The Action has two parameters- "base64file" which is a base 64 file blob
- "filename" the filename which can be a full path
The Action has a respons value "link" which is a link to the uploaded file which is accessible for 5 minutes
Example:
mutation saveFile {
saveFile(base64file: "data:application/pdf;base64,JVBERi0xLjUKJcOkw7zDtsOfCjIgMCB...MGpVCwdiYWZtuglYNVFT0YK", filename: "test/test.pdf")
}
- an Action(Query) to get a file link "loadFile".
The Action has one parameter - "filename" the filename which can be a full path
The Action has a respons value "link" which is a link to the uploaded file which is accessible for 5 minutes
Example:
query MyQuery {
loadFile(path: "test/test.pdf") {
link
}
}
The functions need two environment variables to work:
- HASURA_CLOUD_FUNCTION_SECRET the secret can be found in our google-cloud-secret-manager
- HASURA_BUCKET the bucket name to determine which bucket to upload to
I have not done much in way of a proper error management such as html responses if something goes wrong or security such as checking for allowed file types and sizes etc.
from eduhub.
As of #209 this behavior has changed. There are now different actions for each file:
- loadAchievementCertificate : gets a SignedUrl from google to the achievementCertificate specified in the path parameter that is valid for 5 minutes. the fitting path parameter can be gotten from the achievementCertificateUrl field of the CourseEnrollment table.
- loadAchievementCertificateTemplate : gets a SignedUrl from google to the achievementCertificateTemplate specified in the path parameter that is valid for 5 minutes. the fitting path parameter can be gotten from the achievementCertificateTemplateUrl field of the Program table.
- loadParticipationCertificate : gets a SignedUrl from google to the participationCertificate specified in the path parameter that is valid for 5 minutes. the fitting path parameter can be gotten from the participationCertificateUrl field of the CourseEnrollment table.
- loadParticipationCertificateTemplate : gets a SignedUrl from google to the participationCertificateTemplate specified in the path parameter that is valid for 5 minutes. the fitting path parameter can be gotten from the participationCertificateTemplateUrl field of the Program table.
- saveAchievementCertificate : saves the given achievementCertificate (encoded as a base64 file) to the google bucket. The return value is a relative path that should be saved in the achievementCertificateUrl field in the CourseEnrollment table to be used with the loadAchievementCertificate action
- saveAchievementCertificateTemplate : saves the given achievementCertificateTemplate (encoded as a base64 file) to the google bucket. The return value is a relative path that should be saved in the achievementCertificateTemplateUrl field in the Program table to be used with the loadAchievementCertificateTemplate action
- saveAchievementRecordCoverImage : saves the given achievementRecordCoverImage (encoded as a base64 file) to the google bucket. The return value is a url to a public file in the google bucket and should be saved in the coverImageUrl field of the AchievementRecord table for future retrieval
- saveCourseImage : saves the given courseImage (encoded as a base64 file) to the google bucket. The return value is a url to a public file in the google bucket and should be saved in the coverImage field of the Course table for future retrieval
- saveParticipationCertificate : saves the given participationCertificate (encoded as a base64 file) to the google bucket. The return value is a relative path that should be saved in the participationCertificateUrl field in the CourseEnrollment table to be used with the loadParticipationCertificate action
- saveParticipationCertificateTemplate : saves the given participationCertificateTemplate (encoded as a base64 file) to the google bucket. The return value is a relative path that should be saved in the participationCertificateTemplateUrl field in the Program table to be used with the loadParticipationCertificateTemplate action
- saveUserProfileImage : saves the given userProfileImage (encoded as a base64 file) to the google bucket. The return value is a url to a public file in the google bucket and should be saved in the picture field of the User table for future retrieval
from eduhub.
- saveAchievementRecordDocumentation : saves the given achievementRecordDocumentation (encoded as a base64 file) to the google bucket. The return value is a relative path that should be saved in the documentationUrl field in the AchievementRecord table to be used with the loadAchievementRecordDocumentation action
- loadAchievementRecordDocumentation : gets a SignedUrl from google to the achievementRecordDocumentation specified in the path parameter that is valid for 5 minutes. the fitting path parameter can be gotten from the documentationUrl field of the AchievementRecord table.
from eduhub.
Related Issues (20)
- Prevent course instructors from deleting past sessions
- The achievement certificates are not displayed for the users
- Display of last uploaded achievement is not course dependent
- Error when changing the name in user account HOT 2
- Some profile images are not displayed
- Extend time for changing password
- Fix attendances styling on course detail page
- Reminder with essential information before the start of a course
- Show date for attendances in course admin view
- Add functionality to change the order of the slider groups in the app settings
- Display of the selected project titles of participants in the admin view under "Participations and Achievements"
- Default vaue for session start and end times
- Correct resizing for compiled markdown and add link to instructions in manage course view
- Download of documentation templates fails HOT 4
- Display of the date of submission of proof of performance under "Teilnahmen und Leistungen"
- Add course dates to certificates of attendance HOT 1
- Display of certicicates
- [BUG]
- Improve performance of the landing page
- Implementing of a widget for the tile slider
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eduhub.