After uploading an image to google cloud, how can I get a link to that image? - google-cloud-storage

After uploading an image, I get back metadata that has a mediaDownloadLink that will download the file when accessed. Is there a way to get a link that will display the image in the browser without downloading it?

In general, any object you set to be publicly accessible (which presumably you wanted to do to use it to host images on a website), you can then access with https://storage.googleapis.com/<bucket>/<object>. You can see this link also if you go to the cloud console and make an object publicly viewable and look for the Public link you can click.
If you have problems with the link downloading instead of displaying by itself in a browser, you may need to make sure the content-type header is set correctly; for example if using ByteArrayContent to upload data using the Java API, you'll want to set a string like "image/jpeg" in its constructor for "type".

Related

Host Image and get it as a link

I have an application built with react.js, node.js, PostgreSQL. I want to host a bunch of images somewhere and store their links in my database. To frontend will retrieve these images and display them.
I tried Icedrive eg:hosted image and google photos but the link which they provide has some interface and cannot be directly displayed in a tag.
What free service I can use?
One can use Imgur. As they provide a direct link option that can be used in a tag.

Remove the auto download of a URL that points to a google bucket

I have files stored on google cloud storage. Google provides me a URL to access this files, but when I access this URL the file is auto downloaded. I wish to know if it is possible to remove or don't allow this auto download when we access the file URL. ;)
The download feature is handled by the client.
Calling the URL for an object stored in a bucket will return the object in the body of the HTTP request, and the client will choose what to do with this data.
If you use a web browser, the choice of downloading or not a file is usually given by the header Content-Type. In general, there are some MIME types that will be displayed on the browser itself (according to Chrome help, videos, images, PDFs and web pages will be displayed directly on the browser), while others will download directly.
To modify the MIME type of the files stored in a bucket, you must change it's metadata, so the browser will behave in the way you want.

Aviary client side implementation vs needing a server side component

I'm planning on building an online image editor. I want to use aviary library for it. https://developers.aviary.com
Can someone explain me how I implement it? More specifically, do I need to send an image to their server in order to modify it? or I just do all the modifications on client side and then save that image to the server?
The editor works by loading the image client-side via a public url, allowing the user to edit the photo in the browser. When the user saves, the image is POSTed to Aviary's server, where it's uploaded to a temporary storage location. You then get a url to that temporary image passed to you in the onSave callback, which you can use to save the image back to your own server.
See a full client-side integration here: https://developers.aviary.com/docs/web/example

Using Parse REST API to link an uploaded image to a parse object, getting access denied when accessing image

I'm using the sample code provided in the REST API docs for uploading an image (my own) and then assigning it to an object in an image table. Image uploads fine, code for associating the image runs fine, and a record is created in the DB.
However, if I try to access the image from the data browser, I get ACCESS DENIED. Why is this so? The image is retrievable via the URL provided after a successful upload, but doesn't appear anywhere in the Parse web UI (should it be ihe Files section of Cloud Code?).
Any input would be helpful. I am working on a few wrinkles to get it working.
The answer to this question is to use the long filename provided in the image upload confirm, and not the short filename example shown in the docs.

Facebook won't render link image on wall post

Need a way for Facebook to render an image in wall posts. Sometimes, all you need to do is copy and paste the link to the image, like here:
But, with the images I need to link to, which are on S3, I get this:
You can click here to verify that the second link is in fact a valid image address (you should see a creepy hand drawn smiley face).
I did this test just using the normal Facebook GUI on the site, but I will be using the answer to this question in my app, which integrates with Facebook via the Open Graph API. (In case anyone thought this question was not programming related).
Anyone know what I need to do to get the second image to render in the post?
The key is image size. Don't ask me what the magic number is, but larger images work and smaller ones don't. It could be that it has to be larger than the preview size that facebook uses.
In my test, I had static website configuration turned off.
My guess is only static links will generate a thumbnail for posts on facebook. The link you are trying to use not a static one.
This is what Facebook gets when trying to generate a thumbnail.
<Error>
<SCRIPT/>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>D577337ADC9FA36A</RequestId>
<HostId>
DN9BnBduVLgHbf2lONA+e/fXQIOuT7W3WOFUPdthdpP2MZQhSLlolTvyJ0t9eZXn
</HostId>
</Error>
Solution :
It turns out that to make it work, you cannot just map any arbitrary subdomain to any arbitrary bucket. The fully qualified subdomain name must be the same as the S3 bucket name.
Suppose the name of your site is static.mydomain.com. Then you need
to create a S3 bucket with that same name, named
static.mydomain.com.
Once you configure that bucket as a S3 static web site, it will have
a URL assigned to it that looks something like http://static.mydomain.com.s3-website-us-east-1.amazonaws.com.
Go to your domain host and map your subdomain to the URL from step 2. In enom.com, that meant mapping the host "static" to the address "static.mydomain.com.s3-website-us-east-1.amazonaws.com" as a CNAME
record.
Source, it will help you host a static site from your S3 account. Use images from that custom domain URL path. That will work.