ixodid
ixodid

Reputation: 2400

Make files public from Google Compute Engine

I'm running RStudio server on an instance of Google Compute Engine. My RScript creates a map file that I would like to include in a public web site.

The file gets created OK.

Separately, I've also created a bucket and can upload images to it, viewing them from a web browser with a URL like this: https://storage.googleapis.com/...

Still, I'm confused as to how to make the image created by the R script viewable by a browser. Does the image have to find its way over to a bucket? Or is it viewable where it is somehow?

Upvotes: 0

Views: 85

Answers (1)

GalloCedrone
GalloCedrone

Reputation: 5065

There are infinite possible solutions depending on what you want to implement and how much time you want to spend on it (and if you are the only one accessing or not and if you can share the file or they are sensible), therefore I will provide you some hints:

  • The easiest one is to upload the file to a Google Storage Bucket, then you can control who can access that link (a single user, a domain or everyone), it could be access by accessing with the browser with the following link: https://storage.googleapis.com/namebucket/folder1/folder2/nome_file

    There is no graphical interface, you will need to know the address to download the file (at the end it is enough to know the name). You will need to create a small script to make sure every time a image is available to upload it to the bucket and to make it public available. Or you can decide to make he bucket itself public.

  • The second possible solution is to do the same but to create an html page REALLY simple, basically a list of links to the files in the bucket, each time you upload a file to the bucket you update the html file. At least you would solve the issue regarding the knowing the names and you can navigate it a bit.

<html><body>
<a href="https://www.w3schools.com">This is a link</a>
</body></html>

  • If you need to expose the resources to more people, or you would like to have something more "nice" graphically you will have to spend more time and build a decent frontend. You can follow thousands of different approaches.

You have really thousands of possibilities.

P.S.

  • Documentation regarding uploading a file to bucket.

  • Documentation regarding managing access to file stored.

  • Notice that in this way depending on the extension of the file you want to share the browser behaves differently, a .txt, a .jpg are shown an .exe is downloaded.

Upvotes: 1

Related Questions