(ctx context.Context, url string, headers map[string]string, sign bool, file io.Reader, isFamily bool)
| 150 | } |
| 151 | |
| 152 | func (y *Cloud189PC) put(ctx context.Context, url string, headers map[string]string, sign bool, file io.Reader, isFamily bool) ([]byte, error) { |
| 153 | req, err := http.NewRequestWithContext(ctx, http.MethodPut, url, file) |
| 154 | if err != nil { |
| 155 | return nil, err |
| 156 | } |
| 157 | |
| 158 | query := req.URL.Query() |
| 159 | for key, value := range clientSuffix() { |
| 160 | query.Add(key, value) |
| 161 | } |
| 162 | req.URL.RawQuery = query.Encode() |
| 163 | |
| 164 | for key, value := range headers { |
| 165 | req.Header.Add(key, value) |
| 166 | } |
| 167 | |
| 168 | if sign { |
| 169 | for key, value := range y.SignatureHeader(url, http.MethodPut, "", isFamily) { |
| 170 | req.Header.Add(key, value) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | resp, err := base.HttpClient.Do(req) |
| 175 | if err != nil { |
| 176 | return nil, err |
| 177 | } |
| 178 | defer resp.Body.Close() |
| 179 | |
| 180 | body, err := io.ReadAll(resp.Body) |
| 181 | if err != nil { |
| 182 | return nil, err |
| 183 | } |
| 184 | |
| 185 | var erron RespErr |
| 186 | _ = jsoniter.Unmarshal(body, &erron) |
| 187 | _ = xml.Unmarshal(body, &erron) |
| 188 | if erron.HasError() { |
| 189 | return nil, &erron |
| 190 | } |
| 191 | if resp.StatusCode != http.StatusOK { |
| 192 | return nil, errors.Errorf("put fail,err:%s", string(body)) |
| 193 | } |
| 194 | return body, nil |
| 195 | } |
| 196 | |
| 197 | func (y *Cloud189PC) getFiles(ctx context.Context, fileId string, isFamily bool) ([]model.Obj, error) { |
| 198 | res := make([]model.Obj, 0, 100) |
no test coverage detected