@Environment(value=CLIENT) public class FileUpload extends Object
Modifier and Type | Class and Description |
---|---|
(package private) static class |
FileUpload.CustomInputStreamEntity |
Modifier and Type | Field and Description |
---|---|
private AtomicBoolean |
cancelled |
private String |
clientVersion |
private File |
file |
private static Logger |
LOGGER |
private org.apache.http.client.config.RequestConfig |
requestConfig |
private String |
sessionId |
private int |
slotId |
private UploadInfo |
uploadInfo |
private UploadStatus |
uploadStatus |
private CompletableFuture<UploadResult> |
uploadTask |
private String |
username |
private long |
worldId |
Constructor and Description |
---|
FileUpload(File file,
long worldId,
int slotId,
UploadInfo uploadInfo,
Session session,
String clientVersion,
UploadStatus uploadStatus) |
Modifier and Type | Method and Description |
---|---|
void |
cancel() |
private void |
cleanup(org.apache.http.client.methods.HttpPost request,
org.apache.http.impl.client.CloseableHttpClient client) |
private long |
getRetryDelaySeconds(org.apache.http.HttpResponse response) |
private void |
handleResponse(org.apache.http.HttpResponse response,
UploadResult.Builder uploadResultBuilder) |
boolean |
isFinished() |
private UploadResult |
requestUpload(int currentAttempt) |
private UploadResult |
retryUploadAfter(long retryDelaySeconds,
int currentAttempt) |
private void |
setupRequest(org.apache.http.client.methods.HttpPost request) |
private boolean |
shouldRetry(long retryDelaySeconds,
int currentAttempt) |
void |
upload(Consumer<UploadResult> callback) |
private static final Logger LOGGER
private final File file
private final long worldId
private final int slotId
private final UploadInfo uploadInfo
private final String sessionId
private final String username
private final String clientVersion
private final UploadStatus uploadStatus
private final AtomicBoolean cancelled
private CompletableFuture<UploadResult> uploadTask
private final org.apache.http.client.config.RequestConfig requestConfig
public FileUpload(File file, long worldId, int slotId, UploadInfo uploadInfo, Session session, String clientVersion, UploadStatus uploadStatus)
public void upload(Consumer<UploadResult> callback)
public void cancel()
private UploadResult requestUpload(int currentAttempt)
private void cleanup(org.apache.http.client.methods.HttpPost request, org.apache.http.impl.client.CloseableHttpClient client)
private void setupRequest(org.apache.http.client.methods.HttpPost request) throws FileNotFoundException
FileNotFoundException
private void handleResponse(org.apache.http.HttpResponse response, UploadResult.Builder uploadResultBuilder) throws IOException
IOException
private boolean shouldRetry(long retryDelaySeconds, int currentAttempt)
private UploadResult retryUploadAfter(long retryDelaySeconds, int currentAttempt) throws InterruptedException
InterruptedException
private long getRetryDelaySeconds(org.apache.http.HttpResponse response)
public boolean isFinished()