Hedera
Search…
Get file info
A query that returns the current state of a file. Queries do not change the state of the file or require network consensus. The information is returned from a single node processing the query.
File Info Response
Field
Description
File ID
The Hedera ID of the file
Key(s)
The current admin key(s) on the account
Size
The number of bytes in the file contents
Expiration Time
The current time at which the file is set to expire
Deleted
Whether or not the file has been deleted
Memo
A short description, if any
Query Signing Requirements
    The client operator account paying for the query fees is required to sign
Constructor
Description
new FileInfoQuery()
Initializes the FileInfoQuery object
1
new FileInfoQuery()
Copied!

Methods

V2
V1
Method
Type
Description
setFileId(<fileId>)
FileId
The ID of the file to get information for (x.y.z)
Java
1
//Create the query
2
FileInfoQuery query = new FileInfoQuery()
3
.setFileId(fileId);
4
5
//Sign the query with the client operator private key and submit to a Hedera network
6
FileInfo getInfo = query.execute(client);
7
8
System.out.println("File info response: " +getInfo);
Copied!
JavaScript
1
//Create the query
2
const query = new FileInfoQuery()
3
.setFileId(fileId);
4
5
//Sign the query with the client operator private key and submit to a Hedera network
6
const getInfo = await query.execute(client);
7
8
console.log("File info response: " +getInfo);
Copied!
Go
1
//Create the query
2
query := hedera.NewFileInfoQuery().
3
SetFileID(newFileId)
4
5
//Sign the query with the client operator private key and submit to a Hedera network
6
getInfo, err := query.Execute(client)
7
8
fmt.Println(getInfo)
Copied!
Sample Output: FileInfo{ fileId=0.0.104926, size=26, expirationTime=2021-02-10T17:48:15Z, deleted=false, keys=[ 302a300506032b6570032100100059296cc51f5d362a3859d3c3c74c6a480cffad9d669a10c1d447ce56e5bf ] }
Method
Type
Description
setFileId(<fileId>)
FileId
The ID of the file to get information for (x.y.z)
Java
1
//Create the query
2
FileInfoQuery query = new FileInfoQuery()
3
.setFileId(fileId);
4
5
//Sign the query with the client operator private key and submit to a Hedera network
6
FileInfo getInfo = query.execute(client);
7
8
System.out.println("File info response: " +getInfo.keys);
9
10
//v1.3.2
Copied!
JavaScript
1
//Create the query
2
const query = new FileInfoQuery()
3
.setFileId(fileId);
4
5
//Sign the query with the client operator private key and submit to a Hedera network
6
const getInfo = await query.execute(client);
7
8
console.log("File info response: " +getInfo.keys);
9
10
//v1.4.4
Copied!

Get query values

V2
Method
Type
Description
getFileId()
FileId
The ID of the file to get contents for (x.z.y)
Java
1
//Create the query
2
FileInfoQuery query = new FileInfoQuery()
3
.setFileId(fileId);
4
5
//Get file ID
6
FileId getFileId = query.getFileId();
7
8
//v2.0.0
Copied!
JavaScript
1
//Create the query
2
FileInfoQuery query = new FileInfoQuery()
3
.setFileId(fileId);
4
5
//Get file ID
6
const getFileId = query.getFileId();
7
8
//v2.0.0
Copied!
Go
1
//Create the query
2
query := hedera.NewFileContentsQuery().
3
SetFileID(newFileId)
4
5
//Get file ID
6
getFileId := query.GetFileID()
7
8
//v2.0.0
Copied!

Last modified 6d ago
Copy link