Arweave Tags

To add tags when uploading to Arweave

What are Tags?

Tags are a field in Arweave transactions composed of an array consisting of name and value pairs. By customizing the content of this field, you can include specific tag information for each transaction.

This feature allows you to easily filter and retrieve the transactions you need using Arweave Tags. Tags are widely used in Arweave transactions. In addition to marking the data you store on Arweave, Tags also allow Arweave gateways to directly add data types to the HTTP response header based on the tagged data type.

The benefit of doing this is that the content recipient, such as a browser, can directly determine the data type from the Content-Type in the header and render it accordingly, such as images, videos, audios, PDFs, and so on.

How to add Arweave Tags

When uploading data to Arweave using the 4EVER Bucket, you can add tags using the S3 Tags method. These tags will be automatically embedded into each Arweave transaction.Arweave Tags are embedded into Arweave transactions based on the Bucket Tag information, and there are two main scenarios:

  1. 1.If you directly upload data using an Arweave Bucket, the tags you added when uploading the files will be embedded.

  2. 2.If you use an IPFS Bucket to sync a specific file to Arweave, the tags associated with that particular file will be embedded.

Please note that modifying Bucket Tags will not change the existing tag content on Arweave, and it will not re-upload the file to Arweave. If you want a file to have different tags, you will need to re-upload the file and attach the new tags.

IPFS-Hash Tag

The IPFS-Hash Tag is a special tag provided by the 4EVER Bucket. For each data uploaded to Arweave through the Bucket, the Bucket automatically calculates the IPFS hash based on the file and embeds the corresponding tag in the Arweave transaction.

This means that you can use the IPFS-Hash Tag to index and retrieve the corresponding file through the Arweave gateway. The benefit of this is that it establishes a bridge between IPFS and Arweave.

You can use Arweave as a permanent backup for IPFS, so if the IPFS network cannot locate the data corresponding to the IPFS hash, you can retrieve the data from Arweave and re-pin it on the IPFS network.

Please note that the IPFS-Hash Tag is automatically generated and embedded by the Bucket, and it does not support customization. It also will not be overwritten by custom tag information.

Content-Type

When it comes to Arweave, Content-Type is a crucial tag that typically refers to the Content-Type found in a webpage. It plays an essential role in defining the type of network file and the encoding of the webpage itself. This determination enables the browser to understand how to read and interpret the file accurately. This explains why you may encounter situations where clicking on a PHP webpage results in downloading a file or an image.

When utilizing the Arweave gateway to retrieve data, it is vital to include the Content-Type header, which informs the client about the actual content type of the returned data. By specifying the appropriate Content-Type, the client can correctly interpret and display the content. Some commonly encountered media format types include:

text/html: HTML format
text/plain: plain text format
text/xml: XML format
image/gif : gif image format
image/jpeg : jpg image format
image/png : png image format

A media format type that begins with application:

application/xhtml+xml: XHTML format
application/xml : XML data format
application/atom+xml: Atom XML aggregation format
application/json: JSON data format
application/pdf : pdf format
application/msword: Word document format
application/octet-stream : Binary stream data (e.g. common file downloads)

The Arweave Content-Type Tag in 4EVER Bucket is defined by the S3 Content-Type method and is not affected by S3 Tags. By default, the Bucket automatically generates and embeds the corresponding Arweave Content-Type Tag based on the file format. You can also customize it during file upload using the Bucket's S3 Content-Type method.

Modifying the Content-Type will not change the existing Content-Type Tag on Arweave, nor will it re-upload the file to Arweave. If you want the file to have a different Content-Type, you need to re-upload the file.

Example tutorial

First, go to the Dashboard and find the corresponding bucket. Enable the "Syncing to ar" option(You can also choose to sync a single file to AR).

Second, add tags to the objects you're uploading. You can do this using the Bucket S3 Compatible API or with a compatible S3 client. Below is an API example:

func ExampleS3_PutObject() {
 svc := s3.New(session.New())
 input := &s3.PutObjectInput{
  Body:                 aws.ReadSeekCloser(strings.NewReader("filetoupload")),
  Bucket:               aws.String("examplebucket"),
  Key:                  aws.String("exampleobject"),
  Tagging:              aws.String("key1=4ever&key2=This is a 4everland tag"),
  //Tagging:              aws.String("key1=value1&key2=value2")
 }

 result, err := svc.PutObject(input)
 if err != nil {
  if aerr, ok := err.(awserr.Error); ok {
   switch aerr.Code() {
   default:
    fmt.Println(aerr.Error())
   }
  } else {
   // Print the error, cast err to awserr.Error to get the Code and
   // Message from an error.
   fmt.Println(err.Error())
  }
  return
 }

 fmt.Println(result)
}

The system will automatically embed the file tags into the Arweave transaction. You can retrieve the corresponding tag information by searching for the hash in the Arweave browser.

Last updated