| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Copyright 2015 Google Inc. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.google.cloud.storage; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
|
|
||
| /** | ||
| * | ||
|
Comment thread
This comment was marked as spam. |
||
| */ | ||
| public class RestartableInputStream { | ||
|
|
||
| InputStream inputStream; | ||
|
Comment thread
This comment was marked as spam. |
||
|
|
||
| public RestartableInputStream(InputStream inputStream) { | ||
| this.inputStream = inputStream; | ||
| this.inputStream.mark(Integer.MAX_VALUE); | ||
|
Comment thread
This comment was marked as spam.This comment was marked as spam. |
||
| } | ||
|
|
||
| public InputStream getInputStream() { | ||
| return this.inputStream; | ||
| } | ||
|
|
||
| public void restart() { | ||
| try { | ||
| this.inputStream.reset(); | ||
| this.inputStream.mark(Integer.MAX_VALUE); | ||
|
Comment thread
This comment was marked as spam.This comment was marked as spam. |
||
| } | ||
| catch (IOException e) { | ||
| throw new IOExpection(); | ||
|
Comment thread
This comment was marked as spam.This comment was marked as spam. |
||
| } | ||
| } | ||
| } | ||
|
Comment thread
This comment was marked as spam. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.google.cloud.storage; | ||
|
|
||
| import com.google.api.client.http.AbstractInputStreamContent; | ||
| import sun.nio.ch.IOUtil; | ||
|
Comment thread
This comment was marked as spam. |
||
|
|
||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.OutputStream; | ||
|
|
||
| public final class RetryableInputStreamContent extends AbstractInputStreamContent { | ||
|
Comment thread
This comment was marked as spam. |
||
|
|
||
| private final RestartableInputStream restartableInputStream; | ||
| private boolean retrySupported = true; | ||
|
|
||
| public RetryableInputStreamContent(String type, RestartableInputStream restartableInputStream) { | ||
| super(type); | ||
| this.restartableInputStream = restartableInputStream; | ||
| } | ||
|
|
||
| @Override | ||
| public InputStream getInputStream() throws IOException { | ||
| return restartableInputStream.getInputStream(); | ||
| } | ||
|
|
||
| @Override | ||
| public long getLength() { | ||
| return this.length; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean retrySupported() { | ||
| return this.retrySupported; | ||
| } | ||
|
|
||
| public RetryableInputStreamContent setCloseInputStream(boolean closeInputStream) { | ||
| super.setCloseInputStream(closeInputStream); | ||
| return this; | ||
| } | ||
|
|
||
| public RetryableInputStreamContent setRetrySupported(boolean retrySupported) { | ||
| this.retrySupported = retrySupported; | ||
| return this; | ||
| } | ||
|
|
||
| public RetryableInputStreamContent setLength(long length) { | ||
| this.length = length; | ||
| return this; | ||
| } | ||
| } | ||
| Back | FazBrowse Home | New Git URL |
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.