@Override public PutObjectResponse putObject(PutObjectRequest request) { LOG.trace("Called putObject"); request = PutObjectConverter.interceptRequest(request); com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = PutObjectConverter.fromRequest(client, request); com.google.common.base.Function<javax.ws.rs.core.Response, PutObjectResponse> transformer = PutObjectConverter.fromResponse(); ib.property( com.oracle.bmc.http.internal.AuthnClientFilter.SIGNING_STRATEGY_PROPERTY_NAME, com.oracle.bmc.http.signing.SigningStrategy.EXCLUDE_BODY); int attempts = 0; while (true) { try { javax.ws.rs.core.Response response = client.put(ib, request.getPutObjectBody(), request); return transformer.apply(response); } catch (com.oracle.bmc.model.BmcException e) { if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS && canRetryRequestIfRefreshableAuthTokenUsed(e)) { continue; } else { throw e; } } } }
/** * Initiates a new upload request. The upload manager will decide whether to use * a single PutObject call or multi-part uploads depending on the {@link UploadConfiguration} * specified. * <p> * Note, if multi-part is used, no MD5 will be returned in the response. Also, if a multi-part * upload attempt fails, the UploadManager will attempt to abort the upload to avoid leaving * partially complete uploads and parts (unless explicitly disabled via UploadConfiguration). * * @param uploadDetails The upload request. * @return The response. * @throws BmcException if the upload fails for any reason. */ public UploadResponse upload(UploadRequest uploadDetails) { if (MultipartUtils.shouldUseMultipart( uploadConfiguration, uploadDetails.putObjectRequest.getContentLength())) { return multipartUpload(uploadDetails); } return singleUpload( uploadDetails, uploadDetails.putObjectRequest.getPutObjectBody(), uploadDetails.putObjectRequest.getContentLength()); }
@Override public PutObjectResponse apply(PutObjectRequest request) { InputStream stream = request.getPutObjectBody(); BmcException ex = null; for (int i = 1; i <= MAX_RETRIES; i++) { try { return service.putObject(request); } catch (BmcException e) { ex = e; if (canRetry(stream, e, i)) { request = PutObjectRequest.builder() .copy(request) .putObjectBody( ((DuplicatableInputStream) stream).duplicate()) .build(); } else { break; } } } throw ex; } };
client.put( ib, interceptedRequest.getPutObjectBody(), interceptedRequest, onSuccess,
MD5Calculation md5Calculation = calculateMd5( putObjectRequest.getPutObjectBody(), putObjectRequest.getContentLength()); putObjectRequest = .putObjectBody( ProgressTrackingInputStreamFactory.create( putObjectRequest.getPutObjectBody(), progressTrackerFactory.getProgressTracker())) .build();
Validate.notBlank(request.getBucketName(), "bucketName must not be blank"); Validate.notBlank(request.getObjectName(), "objectName must not be blank"); Validate.notNull(request.getPutObjectBody(), "putObjectBody is required");
StreamChunkCreator chunkCreator = new StreamChunkCreator( request.getPutObjectBody(), request.getContentLength(), sizePerPart); } finally { StreamUtils.closeQuietly(uploadDetails.putObjectRequest.getPutObjectBody());
/** * Copy method to populate the builder with values from the given instance. * @return this builder instance */ public Builder copy(PutObjectRequest o) { namespaceName(o.getNamespaceName()); bucketName(o.getBucketName()); objectName(o.getObjectName()); contentLength(o.getContentLength()); putObjectBody(o.getPutObjectBody()); ifMatch(o.getIfMatch()); ifNoneMatch(o.getIfNoneMatch()); opcClientRequestId(o.getOpcClientRequestId()); expect(o.getExpect()); contentMD5(o.getContentMD5()); contentType(o.getContentType()); contentLanguage(o.getContentLanguage()); contentEncoding(o.getContentEncoding()); opcMeta(o.getOpcMeta()); invocationCallback(o.getInvocationCallback()); return this; }