MCPcopy Index your code
hub / github.com/peak/s5cmd / Run

Method Run

command/pipe.go:205–258  ·  view source on GitHub ↗

Run starts copying stdin output to destination.

(ctx context.Context)

Source from the content-addressed store, hash-verified

203
204// Run starts copying stdin output to destination.
205func (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

Callers 1

NewPipeCommandFunction · 0.95

Calls 8

shouldOverrideMethod · 0.95
NewRemoteClientFunction · 0.92
InfoFunction · 0.92
printDebugFunction · 0.85
IsBucketMethod · 0.80
IsPrefixMethod · 0.80
PutMethod · 0.80

Tested by

no test coverage detected