how to use sap-hybris media(image) url from out side- or how can link it - media

I want to use the image of sap-hybris by URL , how can get it
Like- some URLs like:https://s3.amazonaws.com/manikart.bbb.dd/LOGO-512x512.png
in this case, I want to use the sap-hybris media but from back-office, I only get this medias/sys_master/images/h50/h25/8855153901598/RapidHybrisLogo512512.png URL.

If you want to access media manually, all you need to do is prefix it with your site URL.
Let's say
Site URL: https://www.test.com/mystorefront
Media URL: /medias/sys_master/images/h50/h25/8855153901598/RapidHybrisLogo512512.png
Now, You can access media with https://www.test.com/mystorefront/medias/sys_master/images/h50/h25/8855153901598/RapidHybrisLogo512512.png
If your requirement is to get the full media URL from the media object itself, then you can create a dynamic attribute say fullMediaURL in the MediaModel and write the logic to concat your basesiteURL with Media downloadURL in your dynamicAttributeProvider class.

You can control generated media url with LocalMediaWebURLStrategy strategy. Extend it as your needs.

Related

Full Media URL in Strapi

The Strapi API responds the media URLs as something like "url:'/uploads/thumbnail.png'".
I would like to get the complete URL that links to my file as value for "url". For example: "url:'https://example.org/uploads/thumbnail.png'"
The documentation also shows the full URL as response. How can I achieve this?
The full URLs come from using an upload provider such as AWS-S3 or Cloudinary. The local provider doesn't support full URLs at the moment.
There are some potentials reasons why you shouldn’t store a full URL, and respond with a full URL. I won’t dive into those reasons.
I suggest creating the entire request/response, or creating a middleware component to intercept the response.
Then you can modify the original url value with the site’s URL. Looping through the results with something like:
const serverHost = strapi.config.get('server.host', 'defaultValueIfUndefined');
url = serverHost + url;
See the following docs for more details:
https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations.html
https://docs.strapi.io/developer-docs/latest/development/backend-customization/middlewares.html#implementation

Destroy image from cloudinary

when I delete the image from my graphql server and using uploader.upload.destroy(public_id), it deletes from media library of cloudinary (https://cloudinary.com/console/media_library/folders/%2F)
but image is still available If I access it via cloudinary endpoint (https://res.cloudinary.com/db9rcrnuw/image/upload/v1576054005/47122.png)
I want to destroy those endpoints as well when the image is deleted.
here, screen.basePath means public_Id of the image
const screen = await ctx.prisma
.deleteScreen({
id: args.screenId
})
.$fragment(fragment);
if (scrn.basePath.length === 5) {
console.log(scrn.basePath.length);
cloudinary.uploader.destroy(screen.basePath, function(error, result) {
console.log(result, error);
});
return screen;
}
The short answer is that this is caused by a combination of not using the 'invalidate' parameter in your destroy API call and a difference between which URL format (i.e. with a version number (v123456789), 'v1' or no version number) the resource is accessed using versus what format your account is configured to send for invalidation.
The first thing to do is ensure that all destroy API calls include the 'invalidate' parameter set to 'true' if you'd like CDN invalidation.
Regarding the URL formats;
The 'v1576054005' that is part of delivery URLs is a version number that is essentially the UNIX timestamp of the upload time of the asset. Its main purpose is to always return the latest image and avoid CDN caching (upload API responses return the URL with the latest upload version). A bit more information on this topic can be found in this article - https://support.cloudinary.com/hc/en-us/articles/202520912-What-are-image-versions.
Please note that there are three possible URL formats Cloudinary can send for invalidation at the CDN, and these are outlined here: https://support.cloudinary.com/hc/en-us/articles/360001208732-What-URL-conventions-are-invalidated
Invalidation requests are sent when you delete or overwrite an image using the Media Library UI, or when you use the SDK/API, and also provide the 'invalidate' parameter, set to 'true'.
By default, all accounts send invalidations for the default format of URL which the SDKs produces, which uses no version number for assets in the root of your account, and a 'v1' placeholder for assets in folders (option 1 from the URL above).
If you were accessing the image with the full version component then that isn't sent for invalidation by default and why you are likely getting a cached copy returned.
In your case, the URL that would've been sent for invalidation would be without a version component (as the resource is in the root folder) i.e.
https://res.cloudinary.com/db9rcrnuw/image/upload/47122.png
Depending on how you are building your URLs, i.e., if you're using the SDK helper methods, taking the URL from the url or secure_url fields of the Upload API response (which use the full version number), will determine the format and thus how your account should be configured to invalidate.
I suggest you to email Cloudinary support (support#cloudinary.com) and share a link to this thread as well as some details on how the URLs you're using are generated so that your account can be configured accordingly.

Resource maps Show to /:id instead of /:id/show

Don't know why this is happening, but when click on show button, the server will receive a GET request of url /:id instead of /:id/show. The REST client is jsonServerRestClient. I use Resource component as the document describes. like:
<Resource list={MyList} edit={MyEdit} show={MyShow} />
If you look at the docs of jsonServerRestClient
https://marmelab.com/admin-on-rest/RestClients.html#json-server-rest
You will note that the GET_ONE rest type will generate /:id url to the server only. Show is not a rest type.

In spring MVC, how to get full request URL including the fragment, like http://stackoverflow.com/myquestion#test=1234

I want to know how to get full request url
I need #test=1234 but using HttpServletRequest request.getRequestURI() or request.getRequestURL().toString()
return path only, like https://stackoverflow.com/myquestion
Help me
#test=123 is called an Anchor. And Anchors are not submitted to the server, they only reside in the Broswer
#see:
How to get the anchor name in HTTP GET?
Retrieving Anchor Link In URL for ASP.Net
Anchors or URL fragments are not sent by the client to the server when requesting for a resource. The anchor's or fragment's are utilized to identify a location within a resource and not a different resource on the server.
Fragment URL is not part of the URL. You can get the anchor using javascript & save them in cookies to retain them.
var anchor = window.location.hash;

URL localization in Lenya

I am trying to localize Lenya publication URLs.
I store URL translation in the Document metadata and rewrite urls with URLRewriter transformator.
e.g. I build
/lenya/default/authoring/en/home
from
/lenya/default/authoring/index.html
But I can't find a simple way to force Lenya to tranlate incoming request URI back to the original path: /lenya/default/authoring/index.html
Really I want to process the request via pipelines using the original URL, not translated.
Is it possible at all? I had tried to add a servlet filter and use dispatcher, but filter can't access documents metadata because Environment object isn't in the processing stack yet at this stage...
(At this moment I see only one way - to update CocoonServlet and Cocoon classes)
Thanks!
I was able to do this via a RequestListener.
In the public void onRequestStart(Environment environment) method I create RequestWrapper with a new real URL and put it into objectModel. Also I change Environment context with a real URL: env.setContext("", realUrl, env.getContext())
This works fine!

Resources