Skip to content
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

#56 integrated SMCloudStore with Azure provider; cleaned Item form in frontend #58

Merged
merged 5 commits into from
Oct 31, 2024

Conversation

Anjali0407-git
Copy link
Collaborator

Fixes #56

Changes Made:

  • Integrated the SMCloudStore library into the Node.js server to establish connections with the Azure Storage provider.

Reasons for Changes:

  • To leverage the scalability and flexibility of cloud storage solutions, integrating with a cloud provider like Azure allows efficient storage and retrieval of image files. This enhances our application's ability to handle media files.

Implementation Details:

  • Set up a new Azure storage account and configured it using the SMCloudStore API for seamless integration.
  • Updated the Node.js server to handle image uploads: images are now received via POST requests and uploaded directly to Azure Storage.
  • Modified the database schema to store image URLs in the container-name/file-name format, facilitating easier and more efficient retrieval.
  • Refactored the frontend to streamline the process of sending images. This involved adjusting the form data handling and ensuring compatibility with the new backend setup.

Screenshots

  • Files uploaded to Azure storage

    image

  • Postgres storing list of filenames from azure storage

    image

… properly upload image files; added new migrations for storing image urls
@Anjali0407-git Anjali0407-git linked an issue Oct 25, 2024 that may be closed by this pull request
@Anjali0407-git Anjali0407-git self-assigned this Oct 25, 2024
Copy link
Collaborator

@kungfuchicken kungfuchicken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Please either address the three comments with either a bit more code, or new Issues.

// upload images to Azure and get their filenames
const imageUrls = await Promise.all(imageFiles.map((file, index) => {
const formattedDate = new Date().toISOString();
return uploadToAzure(file, `item-${formattedDate}-${newItem.id}.jpg`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming .jpg is fine for now, but long-term it might bite you. maybe you want a function to handle detecting file types and generating your uploaded image file name. you could create an issue to do that. it might make a good-first-issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it makes sense. I blindly used .jpg but it could be .png image also. I will try to fix it or create a good first issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this one by creating a function to find the file extension based on incoming file MIME type.

Copy link
Collaborator

@kungfuchicken kungfuchicken Oct 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starting with Azure makes sense based on what we discussed. do you have an issue created to add an option for all the supported platforms? it seems like it would be a straightforward update to this file, the donated item service, and package.json.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writing a new connection for other cloud storage is easy but I have to create accounts for other cloud providers to get the connection keys, storage account etc which is time consuming. I will create an issue for that. What is the purpose of the multiple cloud providers? Is it for fail safe or to be able to switch to other providers in future?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to switch to other providers in the future, especially if the solution is deployed by other users. solving for BWorks is our first use case, but in talking w/ Patrick my understanding is that his vision has always been something that anyone who does similar things could re-use the tool.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense. I will work on that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't see any validation that you're only accepting images, indication what sort of images types might be accepted, or limits on file size. these aren't urgent concerns, but you'll probably want them at least in the client, and probably in the server, at some point. maybe just drop a new issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense, Copied!!

@kungfuchicken
Copy link
Collaborator

@Anjali0407-git
Copy link
Collaborator Author

I have addressed one of the review comments and updated unit tests and now CI pipeline has passed.
And I created the following issues to address other two review comments.
Issue1
Issue2
Issue3

Copy link
Collaborator

@kungfuchicken kungfuchicken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm; Thank you!

@kungfuchicken kungfuchicken merged commit f332a3b into main Oct 31, 2024
3 checks passed
@kungfuchicken kungfuchicken deleted the 56-integrate-sm-cloud-store-into-backend branch October 31, 2024 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate SM Cloud Store into backend
2 participants