NeoFS HTTP gateway

Neo SPCC
4 min readApr 16, 2021

Introduction

In our previous article, we learned how to start using NeoFS in the N3 RC1 testnet. We created our first wallet, made a deposit, and even managed to upload a cat. Want to get it back via your browser? Or let other users obtain such a cutie?

Now, for public containers, you can get access to this picture (or any other object uploaded) using HTTP. We have already deployed several NeoFS HTTP Protocol Gateways as a tech demo for you to start. In our next articles, we are going to tell you how to deploy your own NeoFS HTTP Protocol Gateway. However, first and foremost is that this NeoFS technology will let us soon launch NeoFS.CDN, a truly decentralized distributed content delivery and storage system.

Developers can use HTTP Gateway to integrate their existing applications using HTTP storage backends or web apps with NeoFS. For instance, this gateway can be set behind a common web server and host website assets in NeoFS, as it is done in AWS S3 and other analogues. We provide the HTTP protocol gateway as a technology demonstration and reference for developers. Based on its code, developers can integrate NeoFS into their projects or even write their own services for working with NeoFS API via another protocol. This is a component of our future service — NeoFS CDN, which can be used separately now.

Open your object in the browser

When uploading our cat to NeoFS, we added object attributes and downloaded it back through neofs-cli. Now, you can get it via HTTP and check the uploaded object with a browser wherever you are.

Use our HTTP Gateway for this. Just add the object address (container_ID/object_ID) in browser’s address bar after https://http.fs.neo.org/ domain.

Let’s use a cat.jpg file, uploaded via neofs-cli previously. Following the steps from the previous article, we got an object with Object ID EDdHF638FmU1fyU3FMNbhqkWEWzKZWbzQb8kJaZxhABZ in the Container DMQkED7cNmwiyAy5iaUjE5oHgr4KykPKmCSSYoR2V2rn.

Now we can open it with HTTP Gateway: https://http.fs.neo.org/DMQkED7cNmwiyAy5iaUjE5oHgr4KykPKmCSSYoR2V2rn/EDdHF638FmU1fyU3FMNbhqkWEWzKZWbzQb8kJaZxhABZ

If uploading via neofs-cli, FileName and Timestamp attributes will be defined automatically. Which is definitely good because HTTP Gateway allows us to use FileName attribute to link the object. Let’s try to open the photo by its name cat.jpg:

https://http.fs.neo.org/DMQkED7cNmwiyAy5iaUjE5oHgr4KykPKmCSSYoR2V2rn/cat.jpg.

Develop your first decentralized site

Now, we are ready to upload not just a picture, but a real website to store it in a distributed and decentralized manner on NeoFS.

Create an HTML page index.html that will display the picture with the hilarious cat.

<html>
<body>
<h1> Me and my hilarious cat</h1>
<img src="cat.jpg">
</body>
</html>

If you upload this file in the NeoFS container storing our cat.jpg and open it with HTTP Gateway, you will see the website. As easy as that.

https://http.fs.neo.org/DMQkED7cNmwiyAy5iaUjE5oHgr4KykPKmCSSYoR2V2rn/index.html

Or do it by the name of the container if you have index.html uploaded there:

https://http.fs.neo.org/DMQkED7cNmwiyAy5iaUjE5oHgr4KykPKmCSSYoR2V2rn/

Conclusion

In the future, we are planning to launch a public service NeoFS.CDN. It will let you exploit the decentralized character of NeoFS to the utmost to happily distribute content. It will help the dApp step closer to real decentralization — no need to use centralized services for storing and distributing data.

Enjoy and stay tuned for further updates!

Tips and tricks

“How I update a blog on immutable NeoFS?”

If you delete an object holding the FileName attribute and put another one with the same FileName, after a short cache expiration period it will get replaced. Then HTTP Gateway will return the object with updated contents.

“How I see attributes of my object?”

Use neofs-cli command object head.

neofs-cli {NEOFS_ENDPOINT} -k {key.file} object head --oid {OBJECT_ID} --cid {CONTAINER_ID}

  • {NEOFS_ENDPOINT} — any NeoFS node (e.g., st1.storage.fs.neo.org:8080)
  • {key.file} — private key in hex, WIF, or file path to .key file. We do not recommend using WIF in the command line for security reasons in real workflows.

Disclaimer

Remember, though, that it is Testnet. If you have any problems, mail us via ops@nspcc.ru or file issues on Github. Also, be aware that depending on the capacity of the test network and production needs, we can periodically clear all data stored in N3 TestNet.

The service is designed for individuals 18 years of age or older. As a user of the service, you undertake to follow these terms of service and be responsible for all activities and content you post/upload. In addition to following these terms of service, you are responsible for adhering to all applicable local and national laws. NEO SPCC is not responsible for the content uploaded by users.

--

--