Source:
<code>public ObjectSpecification initiateUpload(String objectId, long fileSize, boolean overwrite) { checkRegistered(objectId); val objectKey = ObjectKeys.getObjectKey(dataDir, objectId); log.debug("Initiating upload for object key: {}, overwrite: {}", objectKey, overwrite); if (!overwrite) { if (exists(objectId)) { val message = String.format("Attempted to overwrite object id %s", objectId); log.error(message); throw new InternalUnrecoverableError(message); } } try { val uploadId = getUploadId(objectId); stateStore.delete(objectId, uploadId); } catch (IdNotFoundException e) { log.info("No upload ID found. Initiate upload..."); } <START> val actualBucketName = BucketResolver.getBucketName(objectId, bucketName, bucketPoolSize, bucketKeySize); <END> val request = new InitiateMultipartUploadRequest(actualBucketName, objectKey); try { s3Conf.encrypt(request); val result = s3Client.initiateMultipartUpload(request); val parts = partCalculator.divide(fileSize); val now = LocalDateTime.now(); val expirationDate = Date.from(now.plusDays(expiration).atZone(ZoneId.systemDefault()).toInstant()); for (val part : parts) { part.setUrl(urlGenerator.getUploadPartUrl(actualBucketName, objectKey, result.getUploadId(), part, expirationDate)); } val spec = new ObjectSpecification(objectKey, objectId, result.getUploadId(), parts, fileSize, false); stateStore.create(spec); return spec; } catch (AmazonServiceException e) { log.error("Multipart Upload Initialization failure", e); if (e.getErrorCode().equals("KMS.DisabledException")) { throw new InternalUnrecoverableError(e); } throw new RetryableException(e); } }</code><technical_language>bucketName configured in BucketResolver, rest, excluding objectId</technical_language>

Target:
public ObjectSpecification initiateUpload(String objectId, long fileSize, boolean overwrite) { checkRegistered(objectId); val objectKey = ObjectKeys.getObjectKey(dataDir, objectId); log.debug("Initiating upload for object key: {}, overwrite: {}", objectKey, overwrite); if (!overwrite) { if (exists(objectId)) { val message = String.format("Attempted to overwrite object id %s", objectId); log.error(message); throw new InternalUnrecoverableError(message); } } try { val uploadId = getUploadId(objectId); stateStore.delete(objectId, uploadId); } catch (IdNotFoundException e) { log.info("Upload id not found. Initiating new upload..."); } val actualBucketName = bucketNamingService.getObjectBucketName(objectId); val request = new InitiateMultipartUploadRequest(actualBucketName, objectKey.getKey()); try { s3Conf.encrypt(request); val result = s3Client.initiateMultipartUpload(request); val parts = partCalculator.divide(fileSize); val now = LocalDateTime.now(); val expirationDate = Date.from(now.plusDays(expiration).atZone(ZoneId.systemDefault()).toInstant()); for (val part : parts) { part.setUrl(urlGenerator.getUploadPartUrl(actualBucketName, objectKey, result.getUploadId(), part, expirationDate)); } val spec = new ObjectSpecification(objectKey.getKey(), objectId, result.getUploadId(), parts, fileSize, false); stateStore.create(spec); return spec; } catch (AmazonServiceException e) { log.error("Multipart Upload Initialization failure", e); if (e.getErrorCode().equals("KMS.DisabledException")) { throw new InternalUnrecoverableError(e); } throw new RetryableException(e); } }