2026-01-30 17:55:37 -03:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include "easystorage.h"
|
|
|
|
|
|
|
|
|
|
void progress(int total, int complete, int status) {
|
|
|
|
|
printf("\r %d / %d bytes", complete, total);
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
if (argc < 2) {
|
|
|
|
|
printf("Usage: %s <filepath>\n", argv[0]);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
node_config cfg = {
|
|
|
|
|
.api_port = 8080,
|
|
|
|
|
.disc_port = 9090,
|
|
|
|
|
.data_dir = "./uploader-data",
|
|
|
|
|
.log_level = "INFO",
|
|
|
|
|
.bootstrap_node = NULL,
|
2026-01-30 18:12:31 -03:00
|
|
|
.nat = "none",
|
2026-01-30 17:55:37 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
STORAGE_NODE node = e_storage_new(cfg);
|
|
|
|
|
e_storage_start(node);
|
|
|
|
|
|
|
|
|
|
char *cid = e_storage_upload(node, argv[1], progress);
|
|
|
|
|
char *spr = e_storage_spr(node);
|
|
|
|
|
|
2026-01-30 18:12:31 -03:00
|
|
|
printf("Run: downloader %s %s ./output-file\n", spr, cid);
|
2026-01-30 18:14:42 -03:00
|
|
|
free(cid);
|
|
|
|
|
free(spr);
|
|
|
|
|
|
2026-01-30 17:55:37 -03:00
|
|
|
printf("\nPress Enter to exit\n");
|
|
|
|
|
getchar();
|
|
|
|
|
|
|
|
|
|
e_storage_stop(node);
|
|
|
|
|
e_storage_destroy(node);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|