文章目录

  • 简介
  • uplink lib
    • uplink go
  • uplink cli
    • uplink配置及使用(和satellite通信)
    • uplink配置及使用(和gateway通信)
  • gateway
    • gateway
    • gateway-mt
  • aws s3 cli测试

简介

uplink是访问storj网络的工具(客户端),主要有三类:1、libuplink 各类语言的类库 2、uplink cli命令行工具 3、gateway 。uplink cli可以直接和satellite交互也可以和gateway交互,由于gateway兼容s3,因此可以使用aws s3 cli与 gateway交互,甚至可以使用s3类库与gateway通信,如果你原来使用的是S3对象存储,可以直接用storj替换。gateway可以看成是一种特殊的uplink

uplink lib

  • go: https://github.com/storj/uplink
  • c: https://github.com/storj/uplink-c
  • java: https://github.com/storj/uplink-java
  • android: https://github.com/storj/uplink-android
  • chrome(webassembly): https://github.com/storj/uplink-chrome

uplink go

需要的参数:

  • APIKey = “change-me-to-the-api-key-created-in-satellite-gui”
  • satellite = “us-central-1.tardigrade.io:7777”
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.package mainimport ("bytes""context""fmt""io""io/ioutil""log""storj.io/uplink"
)const (myAPIKey = "change-me-to-the-api-key-created-in-satellite-gui"satellite    = "us-central-1.tardigrade.io:7777"myBucket     = "my-first-bucket"myUploadKey  = "foo/bar/baz"myData       = "one fish two fish red fish blue fish"myPassphrase = "you'll never guess this"
)// UploadAndDownloadData uploads the specified data to the specified key in the
// specified bucket, using the specified Satellite, API key, and passphrase.
func UploadAndDownloadData(ctx context.Context,satelliteAddress, apiKey, passphrase, bucketName, uploadKey string,dataToUpload []byte) error {// Request access grant to the satellite with the API key and passphrase.access, err := uplink.RequestAccessWithPassphrase(ctx, satelliteAddress, apiKey, passphrase)if err != nil {return fmt.Errorf("could not request access grant: %v", err)}// Open up the Project we will be working with.project, err := uplink.OpenProject(ctx, access)if err != nil {return fmt.Errorf("could not open project: %v", err)}defer project.Close()// Ensure the desired Bucket within the Project is created._, err = project.EnsureBucket(ctx, bucketName)if err != nil {return fmt.Errorf("could not ensure bucket: %v", err)}// Intitiate the upload of our Object to the specified bucket and key.upload, err := project.UploadObject(ctx, bucketName, uploadKey, nil)if err != nil {return fmt.Errorf("could not initiate upload: %v", err)}// Copy the data to the upload.buf := bytes.NewBuffer(dataToUpload)_, err = io.Copy(upload, buf)if err != nil {_ = upload.Abort()return fmt.Errorf("could not upload data: %v", err)}// Commit the uploaded object.err = upload.Commit()if err != nil {return fmt.Errorf("could not commit uploaded object: %v", err)}// Initiate a download of the same object againdownload, err := project.DownloadObject(ctx, bucketName, uploadKey, nil)if err != nil {return fmt.Errorf("could not open object: %v", err)}defer download.Close()// Read everything from the download streamreceivedContents, err := ioutil.ReadAll(download)if err != nil {return fmt.Errorf("could not read data: %v", err)}// Check that the downloaded data is the same as the uploaded data.if !bytes.Equal(receivedContents, dataToUpload) {return fmt.Errorf("got different object back: %q != %q", dataToUpload, receivedContents)}return nil
}func main() {err := UploadAndDownloadData(context.Background(),satellite, myAPIKey, myPassphrase, myBucket, myUploadKey, []byte(myData))if err != nil {log.Fatalln("error:", err)}fmt.Println("success!")
}

uplink cli

代码:https://github.com/storj/storj/tree/main/cmd/uplink
使用说明:https://github.com/storj/storj/wiki/Uplink-CLI
命令:https://documentation.tardigrade.io/api-reference/uplink-cli

uplink配置及使用(和satellite通信)

如果是tardigrade提供的网络则选择 1、2、3,如果是私有测试网络,则需要取satellite 控制台创建grant access(类型选continue in cli),记录下Satellite Address和Token,我们在执行uplink setup时需要填写.

uplink setup
Select your satellite:[1] us-central-1.tardigrade.io[2] europe-west-1.tardigrade.io[3] asia-east-1.tardigrade.io
Enter number or satellite address as "<nodeid>@<address>:<port>" [1]: 1KGyNe7z2YVc3aeSYCipaZN91XD3sGggnJufnutR8uMs65LppA@127.0.0.1:10000
Choose an access name (use lowercase letters) ["default"]:
Enter your API key: 1FkaZdRiVFZwRPYkoecWGAqNZdPFymWxr7n9AYpDRirehEhEQ23B7zqxuS2j7xixk7UVhjuU6h1bDagg7iVrrsCWe9Ptp6H9PfyAk4iyBJmvmepJno2PBZP7yt5826g3m6TpGdLLYb1nU5GJBnxT6
Data is encrypted on the network, with an encryption passphrase
stored on your local machine. Enter a passphrase you'd like to use.
## 输入两次加密密码
Enter your encryption passphrase:
Enter your encryption passphrase again:With your permission, Tardigrade can automatically collect analytics information from your uplink CLI and send it to Storj Labs (makers of Tardigrade) to help improve the quality and performance of our products. This information is sent only with your consent and is submitted anonymously to Storj Labs: (y/n)
yYour Uplink CLI is configured and ready to use!* See https://documentation.tardigrade.io/api-reference/uplink-cli for some example commands

你的api key加密后a写入到~/.local/share/storj/uplink/config.yaml,如accesses.XXX,XXX是我们执行uplink setup配置的access name,没填 默认就是default.可以使用uplink setup配置多个卫星,如果需要连接到其他卫星则需要修改config.yaml的access指向

cat /root/.local/share/storj/uplink/config.yaml
# the serialized access, or name of the access to use
access: defaultaccesses.default: 1AYTtHBwWpNaCRpWrz2aAdEpDhNNM8sjwR8ePqajkBUstgviLyBrHqXfW9oQGdoAmiyBB6U3nYrgCJnjh6icoHXQtyJrtu2qUPNFq7C2bY1pWCbmuup7Ba7M8o7ZURB7NsYSULnuyUTFcB9iLk26cZnUhNacrEsyarxpjE84mVNCp3VbiSGTUwjQi11QzbRsCxoziZiF5oSKFBDgKYQVXXPahHHPoLbKytRVjuka86Fe4ui3R8RvHvJDTmXkKKCDWw53tC1FozP9eo5q9F3mYhvYZHRfHdadgJaC1oJSK

可以通过命令查看有哪些access,并查看access详细信息

$ uplink access list
=========== ACCESSES LIST: name / satellite ================================
default / 1KGyNe7z2YVc3aeSYCipaZN91XD3sGggnJufnutR8uMs65LppA@127.0.0.1:10000
s2 / 1ifoKnrhVrK5M5ot6YdRG4tNJgk2e3agX5VyZCiLDzQ7EbtsVk@127.0.0.1:10010
$ uplink access inspect default
{"satellite_addr": "1KGyNe7z2YVc3aeSYCipaZN91XD3sGggnJufnutR8uMs65LppA@127.0.0.1:10000","encryption_access": {"default_key": "d1HKtRzdk3m6Er3dZMufQupjIh3zdM0m/UKMaUTuCTM=","default_path_cipher": "ENC_AESGCM"},"api_key": "1FkaZdRiVFZwRPYkoecWGAqNZdPFymWxr7n9AYpDRirehEhEQ23B7zqxuS2j7xixk7UVhjuU6h1bDagg7iVrrsCWe9Ptp6H9PfyAk4iyBJmvmepJno2PBZP7yt5826g3m6TpGdLLYb1nU5GJBnxT6","macaroon": {"head": "mtBldtl7l391b-JYDwuOlL4jJAaFyO8ocI8_f73ksrk=","caveats": [{"not_after": "2200-01-01T00:00:00Z","not_before": "2021-03-31T00:56:55.462Z","nonce": "7fRCAQ=="}],"tail": "MKvEppE6u4SznF9us_FW6QWxj1yl6HBeQ0Vypj_UnEo="}
}

mb

$uplink  mb sj://test6
Bucket test6 created

put

$echo  "Very secret ingredient list" |uplink put sj://test6/secret.txt
Created sj://test6/secret.txt

ls

$uplink ls
BKT 2021-03-31 15:30:20 test5
BKT 2021-03-31 15:57:14 test6
$uplink ls sj:/test6
OBJ 2021-03-31 15:58:05           28 secret.txt

cat

$uplink cat sj://test6/secret.txt
Very secret ingredient list

uplink配置及使用(和gateway通信)

直接通过–config-dir指定网关配置目录即可

命令测试 /mb/put/cat/ls
创建一个桶

$ uplink --config-dir /data/storj-test/config/gateway/0/ mb sj://one

往桶里put一个key

$ echo  "Very secret ingredient list" |uplink --config-dir /data/storj-test/config/gateway/0/ put sj://one/secret.txt

查看内容

$ uplink --config-dir /data/storj-test/config/gateway/0/ cat sj://one/secret.txt
Very secret ingredient list

rest.log 为当前目录的文件,将它复制到storj,key值默认为文件名

$uplink --config-dir /data/storj-test/config/gateway/0/ cp rest.log sj://one

查看桶内容

uplink --config-dir /data/storj-test/config/gateway/0/ ls sj://one/
OBJ 2021-03-30 17:36:35           28 secret.txt
OBJ 2021-03-30 17:46:27      1226171 rest.log

共享文件

uplink --config-dir /data/storj-test/config/gateway/0/ share  --url sj://one/secret.txt
Sharing access to satellite 19ixnHMcFhPjRn8iP66EpwpYXyzZXihtyeTCyxM1ph6PDewaoL@127.0.0.1:10000
=========== ACCESS RESTRICTIONS ==========================================================
Download  : Allowed
Upload    : Disallowed
Lists     : Allowed
Deletes   : Disallowed
NotBefore : No restriction
NotAfter  : No restriction
Paths     : sj://one/secret.txt
=========== SERIALIZED ACCESS WITH THE ABOVE RESTRICTIONS TO SHARE WITH OTHERS ===========
Access    : 1AncRH2S9S7CwCkAygf1QpPDz4ns6NmcBh8e5fF5z8jAvVeurYCD1BSVLSRzWpTAcYwjF3LMQC5uoAfZsuVCntF1QN9xtx9JLNMqpUT85X1yc5T4QQ8snmQQE2eQXzhFPkDxrfjvaQVfboi2CR4qFKy8KiHXWMuoFJDjFr4Urg25iz5CppxGmZzhSFTxHQu3vvKGnTCpYnCLMR7iKXSsbBdrH1t6SV62QwJV45bsejr4JW8xSo3iGQTcRFUzvPMe7Mmb6CLrvqCkfguR5X7PnW5bAq3gHbXM1T34soJssKx9gCShR47vBRkesSuGW9err7uaSQvJTydiS7GD23m26VkyGzSwVRfeoZgFtWmah6yi5tP57zQ4LRUTnzQgDQJgECDr34S6hU2twNX6o7b4GKMsf2D7vLNJznaB17SM

gateway

和satellite交互的中介,客户可以通过gateway直接存取数据,最重要的是它提供了一个web console 可以通过ui存取数据,它还兼容s3,可以使用aws s3相关的生态工具。

gateway

基于MinIO,Storj V3网络的S3兼容网关
地址:https://github.com/storj/gateway

gateway-mt

基于MinIO,Storj V3网络的S3兼容网关(beta版本,新增多租户)
地址:https://github.com/storj/gateway-mt

tardigrade提供的us2使用了最新的gateway-mt,现在可以注册使用https://us2.tardigrade.io/login,目前测试阶段可以免费使用

aws s3 cli测试

aws s3 可以指定endpoint为storj gateway

下载并安装aws cli

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

配置 Access Key 和Secret Access ,可以在satellite 控制台创建grant access(类型选continue in browser),再最后一步展开 Gateway Credentials,即可生成。

$ aws configure
---
AWS Access Key ID: [Enter your Gateway's Access Key]
AWS Secret Access Key: [Enter your Gateway's Secret Key]
Default region name: [null]
Default output format: [null]

创建桶

endpoint 是gateway地址

aws s3 --endpoint=http://localhost:11000/ mb s3://two

上传

aws s3 --endpoint=http://localhost:11000/ cp awscliv2.zip s3://two

列出桶下的文件

aws s3 --endpoint=http://localhost:11000/ ls s3://two

stroj uplink相关推荐

  1. uplink端口能接路由器吗_交换机常见的网络故障,你知道如何解决吗?

    很多弱电圈的朋友经常提到网络故障,其中在交换机组网时常见的故障比较多,为了便于大家排除这些故障,在此介绍一些常见的典型故障案例及处理思路.   故障1:交换机刚加电时网络无法通信 [故障现象] 交换机 ...

  2. SUL(supplementary Uplink)

    微信公众号同步更新,欢迎关注同名"modem协议笔记" 5G 载波属于高频段,相同距离下, 频率越高则衰减得越厉害,因而会存在5G 小区覆盖受限的问题.NR中最值得关注的就是UE ...

  3. uplink端口能接路由器吗_这些常见的网络故障,你都知道如何解决吗,一文告诉你解决方法...

    很多弱电圈的朋友经常提到网络故障,其中在交换机组网时常见的故障比较多,为了便于大家排除这些故障,在此介绍一些常见的典型故障案例及处理思路. 故障现象 交换机刚刚开启的时候无法连接至其他网络,需要等待一 ...

  4. 5GNR UpLink子载波选择后补偿问题

    1.子载波做了些什么 子载波在UL中负责过滤一些无效的数据(Invalid),然后将所有有效数据给到补偿模块.在通过补偿模块之后会直接输出到顶层,或者说会离开UL这个大模块. 当然,子载波在给数据的同 ...

  5. 论文笔记《Cell-Free Massive MIMO With Radio Stripes and Sequential Uplink Processing》

    论文笔记<Cell-Free Massive MIMO With Radio Stripes and Sequential Uplink Processing> 与传统的MIMO技术相比, ...

  6. 【NOMA】Resource Allocation for Multi-UAV Aided IoT NOMA Uplink Transmission Systems

    文章链接 文章目录 Introduction: 文章贡献 物理建模 系统构建 信道模型 干扰模型 data rate 计算 问题建模 问题的数学化表达 channel allocation--分配子信 ...

  7. stroj测试网络搭建

    文章目录 前置条件 安装或升级go c tooling pg redis 安装和配置 清除测试网络数据&重建数据库 前置条件 centos7 Go 1.14+ C tooling Postgr ...

  8. uplink端口与普通接口区别_工业显示器和普通液晶显示器的区别

    显示器相信大家并不陌生,而工业显示器就不是每个人都知道了,那么工业显示器和普通液晶显示器是不是一样的?两者有什么区别呢? 技术和优缺点是最能体现两者的区别的,工业显示器应用程序与市面上普通的液晶显示器 ...

  9. uplink端口与普通接口区别_什么是PoE交换机?PoE交换机与PoE+交换机的区别!

    PoE交换机是如今安防行业使用很广泛的一种设备,因为它是是一种为远程交换机(如IP电话或摄像机)提供电力和数据传输的交换机,具有非常重要的作用.而在使用PoE交换机时,就有朋友咨询到,有的PoE交换机 ...

最新文章

  1. 01_字符串处理-----04_在文本中应用ZIpf定律
  2. mysql db2免费下载_DB2ToMysql(DB2导入到Mysql工具)下载
  3. 【财务思维课】固定资产是应该买呢还是租或是借呢?
  4. Golang 入门笔记(二)中
  5. 20175213 2018-2019-2 《Java程序设计》第9周学习总结
  6. 聊聊如何提升推荐系统的结果多样性
  7. js给百度地图上的圆点加自定义动画_three.js实现建筑物纹理流动
  8. 我们为什么要学习 Python、TypeScript 与 Go?
  9. AcWing 240. 食物链
  10. 如何用通俗易懂的语言解释需求变更带来的项目影响
  11. matlab difittool,matlab工具箱下载安装和使用方法的汇总|Toolbox 大全
  12. 已知视频码率、视频时长,怎么计算视频文件大小
  13. 学习配置tomcat虚拟主机
  14. 工作汇报计时器小工具介绍
  15. PHP防红接口,域名防红php源代码
  16. 灰色关联度分析法(GRA)_python
  17. 需要类型转换时请为模板定义非成员函数——条款46
  18. 房卡棋牌戏开发如何决家流失问题
  19. 微信小程序MQTT模拟器 阿里云物联网平台测试
  20. 《JDK学习》使用JDK的keytool生成p12证书

热门文章

  1. 私域流量池怎么运营?从三个点去考虑
  2. Error:403 No valid crumb was included in the request
  3. 程序员在囧途之火葬场惊魂14天
  4. 数字+字母+特殊字符 的正则表达式
  5. 十大web安全扫描工具
  6. (淘宝无限适配)手机端rem布局
  7. 高校房产管理系统中周转房有哪些管理功能和范围
  8. python获取发送到手机的短信,使用python将短信更新发送到手机
  9. 《两日算法系列》之第四篇:隐马尔可夫模型HMM
  10. 淘宝天猫1688通过图片搜索到相关产品API(拍立淘以图搜图API接口调用)