Run starts copying stdin output to destination.
(ctx context.Context)
| 203 | |
| 204 | // Run starts copying stdin output to destination. |
| 205 | func (c Pipe) Run(ctx context.Context) error { |
| 206 | if c.dst.IsBucket() || c.dst.IsPrefix() { |
| 207 | return fmt.Errorf("target %q must be an object", c.dst) |
| 208 | } |
| 209 | |
| 210 | err := c.shouldOverride(ctx, c.dst) |
| 211 | if err != nil { |
| 212 | if errorpkg.IsWarning(err) { |
| 213 | printDebug(c.op, err, nil, c.dst) |
| 214 | return nil |
| 215 | } |
| 216 | return err |
| 217 | } |
| 218 | |
| 219 | client, err := storage.NewRemoteClient(ctx, c.dst, c.storageOpts) |
| 220 | if err != nil { |
| 221 | return err |
| 222 | } |
| 223 | |
| 224 | metadata := storage.Metadata{ |
| 225 | UserDefined: c.metadata, |
| 226 | ACL: c.acl, |
| 227 | CacheControl: c.cacheControl, |
| 228 | Expires: c.expires, |
| 229 | StorageClass: string(c.storageClass), |
| 230 | ContentEncoding: c.contentEncoding, |
| 231 | ContentDisposition: c.contentDisposition, |
| 232 | EncryptionMethod: c.encryptionMethod, |
| 233 | EncryptionKeyID: c.encryptionKeyID, |
| 234 | } |
| 235 | |
| 236 | if c.contentType != "" { |
| 237 | metadata.ContentType = c.contentType |
| 238 | } else { |
| 239 | metadata.ContentType = guessContentTypeByExtension(c.dst) |
| 240 | } |
| 241 | |
| 242 | err = client.Put(ctx, &stdin{file: os.Stdin}, c.dst, metadata, c.concurrency, c.partSize) |
| 243 | if err != nil { |
| 244 | return err |
| 245 | } |
| 246 | |
| 247 | msg := log.InfoMessage{ |
| 248 | Operation: c.op, |
| 249 | Source: nil, |
| 250 | Destination: c.dst, |
| 251 | Object: &storage.Object{ |
| 252 | StorageClass: c.storageClass, |
| 253 | }, |
| 254 | } |
| 255 | log.Info(msg) |
| 256 | |
| 257 | return nil |
| 258 | } |
| 259 | |
| 260 | // shouldOverride function checks if the destination should be overridden if |
| 261 | // the destination object and given pipe flags conform to the |
no test coverage detected