Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 2.34 KB

File metadata and controls

31 lines (22 loc) · 2.34 KB

View code on GitHub

The code in the upload folder is responsible for managing and uploading assets in the Sugar project. It provides a modular approach to handle different storage services and platforms, allowing easy integration with various providers. The main functionalities include preparing assets for upload, uploading assets, and handling errors during the upload process.

For example, the assets.rs file provides functions to manage assets, calculate their sizes, and update their metadata. The errors.rs file defines a custom error type called UploadError for handling various errors that may occur during the upload process. The process.rs file is responsible for uploading assets to a storage system, while the uploader.rs file handles the uploading of assets and defines traits and structs for managing the upload process.

The methods subfolder contains code for handling the upload of assets to different storage services and platforms, such as Amazon S3, Bundlr, NFT Storage, Pinata IPFS, Shadow Drive and Cascade. Each storage method is implemented in a separate file, providing a clean and modular approach to integrating various storage services into the larger project.

Here's an example of how the code in the upload folder might be used in the larger project:

// Initialize the uploader based on the configuration
let uploader = initialize(&sugar_config, &config_data).await?;

// Prepare the assets for upload
uploader.prepare(&sugar_config, &asset_pairs, asset_indices).await?;

// Upload the assets
let upload_errors = uploader.upload(
    &sugar_config,
    &mut cache,
    data_type,
    &mut assets,
    &progress_bar,
    interrupted,
).await?;

This code would initialize an uploader object based on the configuration, prepare the assets for upload, and then upload the assets. The upload_errors variable would contain any errors that occurred during the upload process.

In summary, the code in the upload folder plays a crucial role in managing and uploading assets in the Sugar project. It provides a modular approach to handle different storage services and platforms, making it easy to integrate with various providers. The main functionalities include preparing assets for upload, uploading assets, and handling errors during the upload process.