How I can get the image from URL in Smalltalk? - smalltalk

I have some URL string, how I can get the image from URL? I'm using VisualWorks 9.2

(URI fromString: yourString) readStream will produce a stream to read the data from.
You can also use HttpClient get: url.
You may want to load the TLS plugin parcel in oder to support https.

Related

DownLoad VichBundle file Api Platform

I'm using API platform with VichBundle to store file on the back side and React Native on the Front side.
I've followed the documentation of API platform and the upload part is working well, but I don't know how to download the document.
When I make a GET request I have the entity with the url of the file but I can't do a GET request with this url because there is no route to this file.
Can somebody give me an exemple of how to download file with api platform and Vichbundle.
Thanks
If you are following Api Platfom's documentation your files should be uploaded to your project's ./app/public/media/ folder and available making an HTTP GET request to http(s)://<yourdomain>/public/media/<filename>.<extension>. Just open the URL in your browser.
To get the exact url query yout API for me mediaObject information (for example, /api/media_objects/{id}) and check the contentUrl property.

How to find the source for the SignatureDoesNotMatch error on Minio

Since more than a year we are runnig a single page application (SPA with Angular) which receives Json objects with presigned urls from a .NET Core API. The SPA displays a list and uses the presigned url to display the image/video (directly downloaded from the
Suddenly some of the presigned urls in the list still work, others cause a SignatureDoesNotMatch error when the image/video is embedded. The others work.
<Error><Code>SignatureDoesNotMatch</code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>...
Maybe somebody has experince with Minio/S3 and could help me building a check list for finding the source of this error.
So far I have:
Config (access key, secret key, host): since most urls work, some don't this should be valid
Url generation: for working and not working urls I generate them using the Minio .NET SDK (3.02).
await _minio.PresignedGetObjectAsync(bucket, key, ttl);
await _minio.PresignedPutObjectAsync(bucket, key, ttl);
Mixing get and put urls: Could that be a reason? The screenshots within the bug report showed the presigned urls but I haven't seen an indidicator in the url if it was generated as put or get url.
#monty I do not have enough information to root cause. This can be caused maybe by incorrect encoding of the object name which might have been fixed in the newer version of minio and minio dot-net SDK.
What version of minio are you using? I see that you are using Minio Dotnet 3.0.2 version.
Is it happening with certain file and object names?

How to consume an octet stream from protected endpoint using vue-pdf a vuejs implementation of pdfjs

I want to use the vue-pdf library that is an implementation of pdfjs for vuejs 2.x in order to do the following
Download a PDF from an oauth2 protected endpoint using axios
Render the PDF (octet-stream) using vue-pdf library
and the tricky parts are
Access protected resources
Render PDF that comes as octet stream
Currently there are no examples in the repo to show case these.
After fiddling around with the library, I managed to do achieve the rendering of a pdf from a protected endpoint using the following approach
Make an axios ajax request for the protected resource using necessary auth header and the response type as responseType: 'blob'
Magically create a URL from the downloaded blob object
Set the blob URL in a data variable that is then used by <pdf> component
I have created a Pull Request to the vue-pdf repository with a working example. In the PR replace the URL of axios request with a REST endpoint that returns an octet-stream and you should be all good.
The resulting pdf viewer shown below

Browser perform a request insted of show data uri

My Apache registered a data URI in access log.
/data:image/png%3bbase64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAMAAACeL25MAAAABlBMVEUzlME6qNuT3ZmEAAAAE0lEQVQI12NgZGRkYABiMAQzGQEAjAANk73rMwAAAABJRU5ErkJggg==
Apparently some browser did not understand the data URI and performed a request.
How to solve it?
Use some feature detector on client side (for example, Modernizr). And then check whether this feature is supported on document load. If it is not - replace all such urls with, for example, a path to a blank image.
In addition you could just block data uris in you firewall or on your front-end server.

Adobe AIR: How do I get the current endpoint URI?

I need to open a HTTP link to the webserver which my air app is talking to but I don't want to hard-code the webserver URL into the Flex code. If I can get the endpoint URI then I can work from there. I'm using GraniteDS in case that is relevant.
import mx.messaging.config.ServerConfig;
ServerConfig.getChannel(CHANNEL_ID).uri;