func (s Service) UploadEx(upToken string, localFile, entryURI string, mimeType, customMeta, callbackParam string, crc int64, rotate int) (ret PutRet, code int, err error) { action := "/rs-put/" + rpc.EncodeURI(entryURI) if mimeType == "" { mimeType = "application/octet-stream" } action += "/mimeType/" + rpc.EncodeURI(mimeType) if customMeta != "" { action += "/meta/" + rpc.EncodeURI(customMeta) } if crc >= 0 { action += "/crc32/" + strconv.FormatInt(crc, 10) } if rotate >= 0 { action += "/rotate/" + strconv.FormatInt(int64(rotate), 10) } //url := "http://up.qbox.me" + "/upload" //url := "http://m1.qbox.me" + "/upload" //url := "http://m1.qbox.me" + "/upload" url := s.ip["up"] + "/upload" multiParams := map[string][]string{ "action": {action}, "file": {"@" + localFile}, "auth": {upToken}, } if callbackParam != "" { multiParams["params"] = []string{callbackParam} } code, err = s.Conn.CallWithMultipartEx(&ret, url, s.host["up"], multiParams) return }
func (t *RPtask) Mkfile() (code int, err error) { var ( ctx string ) for k, p := range t.Progress { if k == len(t.Progress)-1 { ctx += p.Ctx } else { ctx += p.Ctx + "," } } bd := []byte(ctx) url := t.ip + "/rs-mkfile/" + rpc.EncodeURI(t.EntryURI) url += "/fsize/" + strconv.FormatInt(t.Size, 10) if t.Meta != "" { url += "/meta/" + rpc.EncodeURI(t.Meta) } if t.Customer != "" { url += "/customer/" + t.Customer } if t.CallbackParams != "" { url += "/params/" + t.CallbackParams } code, err = t.Conn.CallWithEx(nil, url, t.host, "", strings.NewReader(string(bd)), int64(len(bd))) return }
func (s *Service) Put( entryURI, mimeType string, body io.Reader, bodyLength int64) (ret PutRet, code int, err error) { if mimeType == "" { mimeType = "application/octet-stream" } url := s.ip["io"] + "/rs-put/" + rpc.EncodeURI(entryURI) + "/mimeType/" + rpc.EncodeURI(mimeType) code, err = s.Conn.CallWithEx(&ret, url, s.host["io"], "application/octet-stream", body, (int64)(bodyLength)) return }
func (s *Service) Image(bucketName string, srcSiteUrls []string, srcHost string, expires int) (code int, err error) { url := s.ip + "/image/" + bucketName for _, srcSiteUrl := range srcSiteUrls { url += "/from/" + rpc.EncodeURI(srcSiteUrl) } if expires != 0 { url += "/expires/" + strconv.Itoa(expires) } if srcHost != "" { url += "/host/" + rpc.EncodeURI(srcHost) } return s.Conn.CallEx(nil, url, s.host) }
func (s *Fileop) Mogr(ret interface{}, url string, params map[string]string) (code int, err error) { url1 := url + "?imageMogr" if thumb, ok := params["Thumbnail"]; ok && thumb != "" { url1 += "/thumbnail/" + thumb } if gravity, ok := params["Gravity"]; ok && gravity != "" { url1 += "/gravity/" + gravity } if crop, ok := params["Crop"]; ok && crop != "" { url1 += "/crop/" + crop } if quality, ok := params["Quality"]; ok && quality != "" { url1 += "/quality/" + quality } if rotate, ok := params["Rotate"]; ok && rotate != "" { url1 += "/rotate/" + rotate } if format, ok := params["Format"]; ok && format != "" { url1 += "/format/" + format } if orient, ok := params["Orient"]; ok && orient == "true" { url1 += "/auto-orient" } if entryURI, ok := params["SaveAs"]; ok && entryURI != "" { url1 += "/save-as/" + rpc.EncodeURI(entryURI) } code, err = s.Conn.Call(ret, url1) return }
// 动态获取文件授权后的临时下载链接 func (s *Service) Get(entryURI, base, attName string, expires int) (data GetRet, code int, err error) { url := s.ip["rs"] + "/get/" + rpc.EncodeURI(entryURI) if base != "" { url += "/base/" + base } if attName != "" { url += "/attName/" + rpc.EncodeURI(attName) } if expires > 0 { url += "/expires/" + strconv.Itoa(expires) } //code, err = s.Conn.Call(&data, url) code, err = s.Conn.CallEx(&data, url, s.host["rs"]) if code == 200 { data.Expiry += time.Now().Unix() } return }
func (s *Service) Unstyle(bucketName string, name string) (code int, err error) { return s.Conn.CallEx(nil, s.ip+"/unstyle/"+bucketName+"/name/"+rpc.EncodeURI(name), s.host) }
func (s *Service) Style(bucketName string, name string, style string) (code int, err error) { url := s.ip + "/style/" + bucketName + "/name/" + rpc.EncodeURI(name) + "/style/" + rpc.EncodeURI(style) return s.Conn.CallEx(nil, url, s.host) }
func (s *Service) Separator(bucketName string, sep string) (code int, err error) { return s.Conn.CallEx(nil, s.ip+"/separator/"+bucketName+"/sep/"+rpc.EncodeURI(sep), s.host) }
func (b *Batcher) operate2(entryURISrc, entryURIDest string, method string) { b.op = append(b.op, method+rpc.EncodeURI(entryURISrc)+"/"+rpc.EncodeURI(entryURIDest)) b.ret = append(b.ret, BatchRet{}) }
func (b *Batcher) operate(entryURI string, method string) { b.op = append(b.op, method+rpc.EncodeURI(entryURI)) b.ret = append(b.ret, BatchRet{}) }
func (s *Service) Unpublish(domain string) (code int, err error) { return s.Conn.CallEx(nil, s.ip["rs"]+"/unpublish/"+rpc.EncodeURI(domain), s.host["rs"]) }
func (s *Service) Publish(domain, table string) (code int, err error) { return s.Conn.CallEx(nil, s.ip["rs"]+"/publish/"+rpc.EncodeURI(domain)+"/from/"+table, s.host["rs"]) }
func (s *Service) Copy(entryURISrc, entryURIDest string) (code int, err error) { return s.Conn.CallEx(nil, s.ip["rs"]+"/copy/"+rpc.EncodeURI(entryURISrc)+"/"+rpc.EncodeURI(entryURIDest), s.host["rs"]) }
func (s *Service) Delete(entryURI string) (code int, err error) { return s.Conn.CallEx(nil, s.ip["rs"]+"/delete/"+rpc.EncodeURI(entryURI), s.host["rs"]) }