lightspeedretail / webstore

Web Store eCommerce solution for Lightspeed
http://www.lightspeedpos.com/webstore
Open Software License 3.0
85 stars 63 forks source link

Save product images to s3/cloud instead of server #619

Closed adrianricardo closed 10 years ago

adrianricardo commented 10 years ago

It would be great to have the option to save product images to Amazon s3 or Rackspace clould files instead of saving them locally on the server.

Is this something lightspeed plans to implement? If not is it feasible for me to implement it myself? Could you perhaps point me to where this logic would go?

brandinchiu commented 10 years ago

This is likely something not handled by Web Store. Images are uploaded from LightSpeed. Any logic required to also upload them to a cloud server would have to happen there.

If you want to try and load images manually to these systems, then have web store retrieve them, you would have to extend the product controller, likely in the index method.

adrianricardo commented 10 years ago

gotcha thanks

brandinchiu commented 10 years ago

I also am not sure about fees for use of either service. The images themselves are likely accessed via their api, which will be the same as the src tag.

I warn you though, I've gone through the method used for drawing the product list, and it can be a bit messy at first glance :P. Be careful in there. On May 31, 2014 6:03 PM, "adrianricardo" notifications@github.com wrote:

gotcha thanks

— Reply to this email directly or view it on GitHub https://github.com/lightspeedretail/webstore/issues/619#issuecomment-44760928 .

ktwbc commented 10 years ago

Just to comment on this, we actually experimented with storing images on S3 and it ultimately didn't work out. The reason is because we have different photo sizes depending on the Themes. During the Pro upload process, it saves your original files and also creates thumbnails for the sizes needed for your currently active theme.

If you change themes in Admin Panel and click Refresh, Web Store must quickly regenerate the thumbnails if they are sized differently. On a local file system it's quick, but on S3 it's deadly. Because images are stored remotely and because accessing S3 is basically an FTP-like process, regenerating a thumbnail means redownloading the original to a local temp folder, creating the new image, and reuploading the new size. This can be several sizes per product multiplied by however many products are on the product grid. In the end, S3 by itself isn't really designed for this kind of quick photo turnaround and it was very slow and proved impractical.

You certainly could design a module yourself if you wished. The processing for photos is actually in core/protected/wsphoto.php and it's enabled from the xlsws_modules table where you see an entry for this and active=1. You can turn it off and make an entry for another extension you create (notice the CEventPhoto in category which is how Web Store knows it's a photo processor), and during the upload process you could do anything with the binary image you want inside your own processor, including uploading it to S3.

The entries in the xlsws_image table would need to be created still but if you put in a URL (or more accurately, begin the filename entry with // so it's schemaless), then Web Store will use the remote URL just fine.

adrianricardo commented 10 years ago

Kris thanks so much for your thorough answer!

adrianricardo commented 10 years ago

Hey Kris,

I'm hoping to spin up multiple application servers to handle increased traffic. It seems implementing cloud product images is the only way to be able to have multiple servers other than some type of file syncing across servers right?