Fixed issue with to large ftp upload size
This commit is contained in:
parent
ba73aab706
commit
c42b8fd3d5
2 changed files with 19 additions and 10 deletions
1
.idea/modules/app/app.iml
generated
1
.idea/modules/app/app.iml
generated
|
|
@ -78,6 +78,7 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/../../../app/src/test/shaders" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/../../../app/src/test/shaders" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/assets" />
|
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/assets" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/blame" />
|
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/blame" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/builds" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/bundles" />
|
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/bundles" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/classes" />
|
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/classes" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/classes-proguard" />
|
<excludeFolder url="file://$MODULE_DIR$/../../../app/build/intermediates/classes-proguard" />
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import java.util.regex.Pattern;
|
||||||
*/
|
*/
|
||||||
public class UeBehaviourFtpUpload extends UeBehaviourFtp {
|
public class UeBehaviourFtpUpload extends UeBehaviourFtp {
|
||||||
private static final Logger log = Logger.getLogger(UeBehaviourFtpUpload.class);
|
private static final Logger log = Logger.getLogger(UeBehaviourFtpUpload.class);
|
||||||
private static final int BUFFER_SIZE = 512;
|
private static final int BUFFER_SIZE = 8192;
|
||||||
|
|
||||||
|
|
||||||
@Configurable(order=1, value="Host")
|
@Configurable(order=1, value="Host")
|
||||||
|
|
@ -38,8 +38,8 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
|
||||||
if (outStream != null) {
|
if (outStream != null) {
|
||||||
OutputStream out = new BufferedOutputStream(outStream);
|
OutputStream out = new BufferedOutputStream(outStream);
|
||||||
|
|
||||||
if(sizeOrFile != null && Pattern.matches("\\d*", sizeOrFile)){
|
if(isLong(sizeOrFile)){
|
||||||
int size = Integer.parseInt(sizeOrFile);
|
long size = Long.parseLong(sizeOrFile);
|
||||||
uploadRandomData(out, size);
|
uploadRandomData(out, size);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -55,13 +55,13 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadRandomData(OutputStream out, int size) throws IOException {
|
private void uploadRandomData(OutputStream out, long size) throws IOException {
|
||||||
// Upload data
|
// Upload data
|
||||||
log.debug("Uploading random data with size "+size);
|
log.debug("Uploading random data with size "+size);
|
||||||
int total = 0;
|
long total = 0;
|
||||||
byte[] data = new byte[BUFFER_SIZE];
|
byte[] data = new byte[BUFFER_SIZE];
|
||||||
while (total < size && !stopExecution()) {
|
while (total < size && !stopExecution()) {
|
||||||
int writeLength = (total + data.length < size ? data.length : size - total);
|
int writeLength = (int)(total + data.length < size ? data.length : size - total);
|
||||||
out.write(data, 0, writeLength);
|
out.write(data, 0, writeLength);
|
||||||
|
|
||||||
total += writeLength;
|
total += writeLength;
|
||||||
|
|
@ -109,11 +109,19 @@ public class UeBehaviourFtpUpload extends UeBehaviourFtp {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if(sizeOrFile != null && Pattern.matches("\\d*", sizeOrFile)){
|
if (sizeOrFile != null) {
|
||||||
int size = Integer.parseInt(sizeOrFile);
|
if (isLong(sizeOrFile)) {
|
||||||
return "Will upload "+ StringUtil.getByteString(size) +" of random data.";
|
long size = Long.parseLong(sizeOrFile);
|
||||||
|
return "Will upload " + StringUtil.getByteString(size) + " of random data.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return "Will upload local file " + sizeOrFile;
|
||||||
}
|
}
|
||||||
return "Will upload local file "+ sizeOrFile;
|
else
|
||||||
|
return "No file specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLong(String str){
|
||||||
|
return sizeOrFile != null && Pattern.matches("\\d{1,19}", str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue