Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an Example for "Get file contents" functionality #2513

Open
ivaylogarnev-limechain opened this issue Sep 11, 2024 · 0 comments
Open
Labels
enhancement New feature or request good first issue candidate Issues that can become a good first issue but need more description/context.

Comments

@ivaylogarnev-limechain
Copy link
Contributor

ivaylogarnev-limechain commented Sep 11, 2024

Problem

The Hedera Java SDK includes a useful example, GetFileContentsExample.java, which demonstrates how to retrieve the contents of a file stored on the Hedera network. This example is crucial for developers who need to interact with Hedera’s File Service and fetch file data for further processing or validation.

However, there is no equivalent example available in the Hedera JavaScript SDK. Developers using the JavaScript SDK would benefit from an example that demonstrates how to query and retrieve file contents from Hedera, showcasing the ease of interacting with files stored on the network.

Solution

Below is a link to the existing Java implementation, which can serve as a basis for creating the JavaScript example:
GetFileContentsExample.java

Steps to Implement

  1. Client and operator setup: Set up the Hedera Client in the JavaScript SDK using setOperator.
  2. File contents query:
    • Use FileContentsQuery to query the contents of a specific file on the network.
    • Specify the file ID for the file you want to retrieve.
    • Set appropriate transaction fees to ensure the query is executed successfully.
  3. Processing the file contents:
    • Demonstrate how to output or further process the file contents (for example, printing the file data to the console).
  4. Logging and output: Include appropriate console logs for each step of the process, from initiating the query to retrieving the file contents, so that users can follow along.
  5. Error handling: Add error handling for common cases like non-existent files or access issues.

Expected Outcome

This new example will help developers using the JavaScript SDK understand how to retrieve file contents from the Hedera network. It will demonstrate how to leverage the File Service for real-world applications where file data needs to be queried and processed. Developers will also gain insight into handling file queries, managing fees, and interpreting query results.

By providing this JavaScript example, we align the JavaScript SDK with the Java SDK in terms of documentation and usability, making it easier for developers to build Hedera-based applications.

@ivaylogarnev-limechain ivaylogarnev-limechain added enhancement New feature or request good first issue candidate Issues that can become a good first issue but need more description/context. labels Sep 11, 2024
@ivaylogarnev-limechain ivaylogarnev-limechain changed the title Create an Example for "Create Account with Threshold Key" functionality Create an Example for "Get file contents" functionality Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue candidate Issues that can become a good first issue but need more description/context.
Projects
None yet
Development

No branches or pull requests

1 participant