throws UnsupportedStorageOperationException, RemoteStorageException
{
if (!(item instanceof StorageFileItem)) {
throw new UnsupportedStorageOperationException("Storing of non-files remotely is not supported!");
}
final StorageFileItem fileItem = (StorageFileItem) item;
final ResourceStoreRequest request = new ResourceStoreRequest(item);
try {
validatePath(repository, request);
}
catch (ItemNotFoundException e) {
throw new RemoteStorageException("Invalid path to store", e);
}
final URL remoteUrl = appendQueryString(repository, request, getAbsoluteUrlFromBase(repository, request));
final HttpPut method = new HttpPut(remoteUrl.toExternalForm());
final InputStreamEntity entity;
try {
entity =
new InputStreamEntity(new InterruptableInputStream(fileItem.getInputStream()), fileItem.getLength());
}
catch (IOException e) {
throw new RemoteStorageException(e.getMessage() + " [repositoryId=\"" + repository.getId()
+ "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]",
e);
}
entity.setContentType(fileItem.getMimeType());
method.setEntity(entity);
final HttpResponse httpResponse = executeRequestAndRelease(repository, request, method, repository.getRemoteUrl());
final int statusCode = httpResponse.getStatusLine().getStatusCode();