Our product-specific images are at CDN and we want to store the image URL.
I found that we can do it in ProductContent with image type [PcntImageUrlOriginal]. Do we have an existing service?
You can use the inbuilt crud service:
create#mantle.product.ProductContent and set the contentLocation to a url I guess
The following is not an option as it receives the contents of the file as well as the extension but down below uses the inbuilt crud service.
mantle.product.ProductServices.create#ProductContent
declared in mantle-usl/service/mantle/product/ProductServices.xml
Related
I have image upload in my system. I am struggling to understand what is the logic of serving images.
If I upload directly to wwwroot, the files will be accessible to everyone, which is not what I want.
I understand I could save the file contents in the database as base64 but those can be big files, and I would like them on the server in files.
I could convert them on the fly when requested. Most probably getting the path to file, then loading it in a memory stream and spitting out the base64. But seems overkill, and not an elegant solution. I use Automapper for most data and I have to write some crazy custom mappers, which I will If there is no other way.
I could create virtual path, which from what I understand maps physical path on server to a url which doesn't seem any different than option 1
I fancy there is a way to spit out a link/url that this user has access to (or at least logged users) that can be passed to the app so it can load it. Is this impossible or unreasonable? Or am I missing something?
What is the correct way of doing in general?
Also, what is a quick way to do it without spending days for setup?
To protect the specific static files, you can try the solutions explained in this official doc.
Solution A: Store static files you want to authorize outside of wwwroot, and call UseStaticFiles to specify a path and other StaticFileOptions after calling UseAuthorization, then set the fallback authorization policy.
Solution B: Store static files you want to authorize outside of wwwroot, and serve it via a controller action method to which authorization is applied and return a FileResult object.
I am trying to upload an image to s3 bucket from CkEditor5. My front-end is built on vue and backend is on NodeJs. The uploading of images is working as expected as i can see the image is being saved to s3 bucket correctly. However I am having a confusion whether the bucket should be public or not ?
How CkEditor behaves to image uploading?
The ckEditor uses a simple upload adapter which uses its own built-in adapater that enables image uploading feature. When an images is dropped/copy-pasted to the ckEditor, it makes an http POST request to my backend NodeJs server and server in turns makes a call to S3 to upload that image(till this point everything is working as expected).
Now in order to embed an image inside CkEditor5, the server should respond with an URL attribute as JSON response like following so that CkEditor can fetch it and display inside editor.
{
url: url-path-of-image //full path of image in s3 bucket
}
This is where I am confused and need some pointers.
Question 1:
Should I make it public ? If yes, then what do I do about security, making it public will give access to anybody.
If I make it accessible with key/secret, how do I do it ?
Question 2:
This one is related to question#1
If I make it public then question#2 will not be an issue.However if I am not allowed to make it public in that case how would i display the images in normal div element ? Later on I need to display the content of CkEditor inside a div, with html parsing meaning inside a v-html attribute.
Any suggestions or pointers would be much helpful. Really appreciate taking time to read through the question.
I am not sure I am looking for the solutions. I can tell that it is related to signed urls in AWS S3. You keep bucket private, upload image to S3 and generate a signed url whenever you need to display the image to user on frontend.
If you learn more into the correct implementation please let me know.
Why I can't update image this way?
Bigcommerce::createProductImage($product_id, array('image_file'=>'/home/user/bigcommerce/api/picture.jpg'));
The follow code works:
Bigcommerce::createProductImage($product_id, array('image_file'=>'https://cdn6.bigcommerce.com/s-0cvdh/products/32/images/299/apitec71q__46081.1484240387.1280.1280__30161.1484331218.1280.1280.jpg'));
According to the documentation, it is not possible to upload an image locally. The docs say:
When specifying a product image, the image_file should be specified as either:
a path to an image already uploaded via FTP to the import directory (with the path
relative to the import directory); or a URL to an image accessible on the internet.
It doesn't work because the BigCommerce servers have no idea where "/home/user/bigcommerce/api/picture.jpg" lives. That's a file that exists on your local machine, and you're passing a string to BigCommerce telling it where to get the file. It works in the second case because BigCommerce can access that URI.
In more general terms, you need to upload the image to a location that BigCommerce can access it, and then pass a URI that BigCommerce can use to retrieve the image. It may seem a little cumbersome, but it relieves BigCommerce from having to stream large amounts of data through their API.
Hi I was looking in the imageresizing.net project to see if there is a plugin that handle this but I didnt find it.
I need to set up imageresizer to handle images with prefix, the prefix will define the size and different properties of the resized image.
Example is on disk we have the image
/Images/Folder1/12345.jpg
So the request would be like
/Images/Folder1/small_12345.jpg
So i need to handle the request, take the prefix (small in this case) and based on an xml decide what properties apply to the original image, transforming that to
/Images/Folder1/12345.jpg?w=100&h=75...
This bacause we already have that naming convention and we dont want to change that from our web app, but we are moving from have a batch processing of images everyday to do it on the fly with image resizer.
So the question is there a plugin for something like this or what solution do you recommend? I was thinking on create an httpmodule wrapper that intercept this kind of image names, read the configuration from the xml based on the prefix and call the new url with the image resizer format, thing is I dont want to redirect the user.
Thanks
This is basic URL rewriting - you can do it with any URL rewriting module, or using ImageResizer's own URL rewriting API - the Rewrite event.
The FolderResizeSyntax plugin is an example of this.
I'm currently building a API service that accepts Input in HTTP Requests, processes the information, uses a template engine (Currently Jade) to parse the Template files and then outputs in either HTML, PDF or a Image.
I would like to have this service not be bound to a Database, as I don't see a need for it. The service has one goal, accept input and output the result in the desired format.
Currently I can't decide on how to store and read my templates, it's a new world without a database....
Do I store them in a folder such as "templates" which I read each time I want a list of templates ? But have no idea how and if file locks will cause problems ?
Any suggestions ?
Have a look at Express.js it will allow you to set up a project with a good default directory structure. By default it stores Jade templates in 'views'. There will be no problems with file locking.
One other thing I would do is separate the API service from the view rendering. At the moment I use restify for pure REST services it is specifically geared toward that use case. So the workflow would roughly look as follows
'views' folder <--> Jade templates <--> Express <--> JSON data <--> REST API