Upload and Serve Images to S3?

Hi!, right now I need to upload to our S3 bucket our images, could anyone indicate me what would be the better way to work around it?
I though about using the “update_image” hook alongside the “update_images_pair” one, using $image_data and $image_path to update the location of the file, but I ran into some issues.

First, I dont know what the “image_data” array contains, as there is not documented anywhere and printing it gives no result.
And then, I have the hunch that the file is gonna upload to the server locally anyway, so I wanted first to ask here, as the code itself its no issue, its understanding how CS-Cart handles all the image upload that is giving me all this headache.
Anyone could help me or at least provide me with more info than the official documentation in this aspect? Thanks.

Im gonna keep updating this in case anyone in the same situation as me wants to follow my steps or someone ends up helping.
I managed to upload the files to my S3 Bucket, but it STILL uploads the product to my server, and gets the URL from localhost.
Would love to do it via Hooks, but as I dont know better, I think Im gonna have to just develop into the core files.

Maybe I don’t understand your issue (in which case, please correct me), but if you want to upload images to your store products, can’t you use the standard product import?
Product import requires providing only a link to the image - the rest of the parameters is handled by the script.

Want I want to do, its upload my store product’s images into a S3 bucket and use the URL from my bucket. That way when I retrieve the images from my front its gonna be faster than storing them locally from my CS-Cart server.

Hi! In this case you may create your own realization of the \Tygh\Backend\Storage\ABackend class. You can look at the realization of the \Tygh\Backend\Storage\File class, that extends the ABackend for examples.

Once done, you will need to update the store’s settings to use the new Storage. Please check the POST update_storage mode in the app/controllers/backend/storage.php controller to check the example of how to change the storage.

1 Like

Thanks, Ill try that and see if I have better luck.