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
Related
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.
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.
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;
Title sums it up fairly well.
Said site has cookies, I need to post data from a textbox as a value on said site, and get one of two variables back. I was reading through some tutorials and a few Windows phone 7 books. None of them were related to what I was trying to do. They only dealt with single whole files or something that could be made into a URL. I could also do it that way if someone had a way to also use cookies and just send it as a url [but i do not know how to construct the url in such a way to make that a realistic solution].
You should be able to send cookie's using code like:
CookieContainer container = new CookieContainer();
container.Add(new Uri("http://yoursite"), new Cookie("name", "value"));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://yoursite");
request.CookieContainer = container;
request.BeginGetResponse(new AsyncCallback(GetData), request);
Code borrowed from HttpWebRequest and Set-Cookie header in response not parsed (WP7)
If the server is expecting to use cookies (e.g. for authentication) then there is no way that you'll be able to use form variables/query parameters instead.
You need to use a tool called Fiddler to inspect the calls that the website currently makes - this will include a mixture of:
cookie variables - especially for authentication
get variables - passed within the url path
and post variables - passed within the body of the request
If you do need to do a full POST, then you will need to set variables like - request.Method and request.ContentType - and you will need to brovide a RequestStream. There are libraries you can use like HAMMOCK to help - or I've got some example code in iron7 - see the DoCodePost method at the botom of this uploader class - or take a look at lots of other projects on CodePlex and GitHub.
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!