-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/image service #3
Conversation
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.
Hello, sorry for late notice. One question, don't we need any access key or secret key in order to manage our S3 bucket?
it's in |
If the prod bucket is not AWS, so we need to change our codes in the future right? |
yes, but Tar said it is AWS-compatible, so I hope the code would stay the same. |
Business Logic
image.FindByPetId(): finds images of that pet
image.Upload(): uploads to S3 and create a row with url of that S3 (empty foreign key)
If upload has field petId, then it create the row with petId (have foreign key)
image.AssignPet(): assigns row with specified url with that pet id (add foreign key)
image.Delete(): deletes row and object in S3
When creating pet
For image upload, keep the url from response, imageService.Upload(file) returns Image
For pet create, attach images’ urls into the POST request, petService.Create(pet + urls) ==calls==> imageService.AssignPet(urls, petId)
If delete image, imageService.Delete(id)
When updating pet
If delete image -> imageService.Delete(id) (image id got from petService.FindOne() fetched by client)
If upload image -> imageSrv.Upload(petId)
How to connect S3 bucket
make an AWS account, make an S3 bucket in ap-southeast-1 region, name it anything and paste the name in
config.yaml
, make sure S3 bucket has public policyTests
(FindPetById, AssignPet needs to wait for johnjud-backend)
Upload
Delete
file's URL works