本文整理汇总了Golang中github.com/AaronGoldman/ccfs/objects.HCID.Hex方法的典型用法代码示例。如果您正苦于以下问题:Golang HCID.Hex方法的具体用法?Golang HCID.Hex怎么用?Golang HCID.Hex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/AaronGoldman/ccfs/objects.HCID
的用法示例。
在下文中一共展示了HCID.Hex方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetBlob
func (a appsscriptservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
quarryurl := fmt.Sprintf(
"%s%s%s%s%s%s",
"https://",
"script.google.com",
"/macros/s/AKfycbzl2R7UR2FGGVdgl_WbKabbIoku66ELRSnQ4pbkmBgDdWWvgh8b/exec?",
//"/macros/s/AKfycbxyU7ABEmq4HS_8nb7E5ZbtJKRwuVlLBwnhUJ4VjSH0/dev?",
"type=blob",
"&hcid=",
h.Hex(),
)
//log.Println(quarryurl)
resp, err := http.Get(quarryurl)
if err != nil {
return b, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return b, err
}
data, err := base64.StdEncoding.DecodeString(string(body))
if err != nil {
log.Printf("%s\n", body)
log.Println("error:", err)
return nil, err
}
return data, err
}
示例2: GetBlob
func (k kademliaservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
values := url.Values{}
values.Add("type", "blob")
values.Add("hcid", h.Hex())
data, err := k.getobject(values)
if err != nil {
log.Println(err)
return nil, err
}
return data, err
}
示例3: insertDescendant
func (indexEntry blobIndexEntry) insertDescendant(
versionNumber int64,
descendantHCID objects.HCID,
) blobIndexEntry {
if indexEntry.Descendants == nil {
indexEntry.Descendants = make(map[int64]string)
}
if _, present := indexEntry.Descendants[versionNumber]; !present {
indexEntry.Descendants[versionNumber] = descendantHCID.Hex()
}
return indexEntry
}
示例4: GetBlob
func (m multicastservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
message := fmt.Sprintf("{\"type\":\"blob\", \"hcid\": \"%s\"}", h.Hex())
blobchannel := make(chan objects.Blob, 1)
m.waitingforblob[h.Hex()] = blobchannel
m.sendmessage(message)
select {
case b = <-blobchannel:
return b, err
case <-time.After(150 * time.Millisecond):
//log.Printf("Timing out now")
return b, fmt.Errorf("GetBlob on Multicast service timed out")
}
}
示例5: GetBlob
func (gds googledriveservice) GetBlob(h objects.HCID) (objects.Blob, error) {
if gds.driveService == nil {
return nil, fmt.Errorf("Drive Service not initialized")
}
fileID, err := gds.getChildWithTitle(gds.blobsFolderID, h.Hex())
f, err := gds.driveService.Files.Get(fileID).Do()
fileString, err := gds.DownloadFile(f)
if err != nil {
log.Printf("An error occurred: %v\n", err)
return nil, err
}
log.Printf("Blob %s:\n%q", h, fileString)
return objects.Blob(fileString), err
}
示例6: GetBlob
func (d directhttpservice) GetBlob(h objects.HCID) (objects.Blob, error) {
for _, host := range hosts {
quarryurl := fmt.Sprintf(
"https://%s/b/%s",
host,
h.Hex(),
)
body, err := urlReadAll(quarryurl)
if err != nil {
return objects.Blob{}, err
}
return objects.Blob(body), err
}
return objects.Blob{}, fmt.Errorf("No Hosts")
}
示例7: makeURL
func makeURL(hkid objects.HKID, hcid objects.HCID, typeString string, nameSegment string, version int64) (response string) {
//Path
if typeString == "blob" {
response = fmt.Sprintf("/b/%s" /*host,*/, hcid.Hex())
} else if typeString == "commit" {
response = fmt.Sprintf("/c/%s/%d" /*host,*/, hkid.Hex(), version)
} else if typeString == "tag" {
response = fmt.Sprintf("/t/%s/%s/%d" /*host,*/, hkid.Hex(), nameSegment, version)
} else if typeString == "key" {
response = fmt.Sprintf("/k/%s" /*host,*/, hkid.Hex())
} else {
response = ""
}
return response
}
示例8: GetBlob
func (lfs localfileservice) GetBlob(h objects.HCID) (b objects.Blob, err error) {
//ToDo Validate input
if h == nil {
return nil, fmt.Errorf("[localfileservice] GetBlob() HCID is nil")
}
filepath := fmt.Sprintf("bin/blobs/%s", h.Hex())
//log.Printf("Filepath: %v", filepath)
data, err := ioutil.ReadFile(filepath)
if err != nil {
//log.Printf("\n\t%v\n", err)
return
}
//build object
b = objects.Blob(data)
return b, err
}
示例9: buildResponse
func buildResponse(hkid objects.HKID, hcid objects.HCID, typeString string, nameSegment string, version int64) (response string) {
if typeString == "blob" {
response = fmt.Sprintf("{\"type\": \"blob\", \"hcid\": \"%s\", \"URL\": \"%s\"}", hcid.Hex(),
makeURL(hkid, hcid, typeString, nameSegment, version))
} else if typeString == "commit" {
response = fmt.Sprintf("{\"type\": \"commit\",\"hkid\": \"%s\", \"URL\": \"%s\"}", hkid.Hex(),
makeURL(hkid, hcid, typeString, nameSegment, version))
} else if typeString == "tag" {
response = fmt.Sprintf("{\"type\": \"tag\", \"hkid\": \"%s\", \"namesegment\": \"%s\", \"URL\": \"%s\"}", hkid.Hex(), nameSegment,
makeURL(hkid, hcid, typeString, nameSegment, version))
} else if typeString == "key" {
response = fmt.Sprintf("{\"type\": \"key\",\"hkid\": \"%s\", \"URL\": \"%s\"}", hkid.Hex(),
makeURL(hkid, hcid, typeString, nameSegment, version))
} else {
return ""
}
return response
}