MCPcopy Create free account
hub / github.com/aws/aws-cli / upload

Method upload

awscli/s3transfer/manager.py:305–349  ·  view source on GitHub ↗

Uploads a file to S3 :type fileobj: str or seekable file-like object :param fileobj: The name of a file to upload or a seekable file-like object to upload. It is recommended to use a filename because file-like objects may result in higher memory usage.

(self, fileobj, bucket, key, extra_args=None, subscribers=None)

Source from the content-addressed store, hash-verified

303 return self._config
304
305 def upload(self, fileobj, bucket, key, extra_args=None, subscribers=None):
306 """Uploads a file to S3
307
308 :type fileobj: str or seekable file-like object
309 :param fileobj: The name of a file to upload or a seekable file-like
310 object to upload. It is recommended to use a filename because
311 file-like objects may result in higher memory usage.
312
313 :type bucket: str
314 :param bucket: The name of the bucket to upload to
315
316 :type key: str
317 :param key: The name of the key to upload to
318
319 :type extra_args: dict
320 :param extra_args: Extra arguments that may be passed to the
321 client operation
322
323 :type subscribers: list(s3transfer.subscribers.BaseSubscriber)
324 :param subscribers: The list of subscribers to be invoked in the
325 order provided based on the event emit during the process of
326 the transfer request.
327
328 :rtype: s3transfer.futures.TransferFuture
329 :returns: Transfer future representing the upload
330 """
331 extra_args = extra_args.copy() if extra_args else {}
332 if subscribers is None:
333 subscribers = []
334 self._validate_all_known_args(extra_args, self.ALLOWED_UPLOAD_ARGS)
335 self._validate_if_bucket_supported(bucket)
336 self._add_operation_defaults(extra_args)
337 call_args = CallArgs(
338 fileobj=fileobj,
339 bucket=bucket,
340 key=key,
341 extra_args=extra_args,
342 subscribers=subscribers,
343 )
344 extra_main_kwargs = {}
345 if self._bandwidth_limiter:
346 extra_main_kwargs['bandwidth_limiter'] = self._bandwidth_limiter
347 return self._submit_transfer(
348 call_args, UploadSubmissionTask, extra_main_kwargs
349 )
350
351 def download(
352 self, bucket, key, fileobj, extra_args=None, subscribers=None

Callers

nothing calls this directly

Calls 6

_submit_transferMethod · 0.95
CallArgsClass · 0.90
copyMethod · 0.45

Tested by

no test coverage detected