-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Labels
Description
upload 0 Kb. Flow is my test code. wanna to help me.
package org.bklab.wot.warmonger;
import org.aarboard.nextcloud.api.NextcloudConnector;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@SuppressWarnings("unused")
public class UploadToBlueHawkCloud {
private NextcloudConnector lanyingCloud = getConnection();
private static final String base = "warmongers";
private String s = initString();
public static UploadToBlueHawkCloud create() {
return new UploadToBlueHawkCloud();
}
public NextcloudConnector getConnection() {
return new NextcloudConnector("example.com", true, 443, "admin", "password");
}
public UploadToBlueHawkCloud doUpload() {
File upLoadDir = new File("E:\\Broderick Resources\\mods\\");
List<File> modsList = Arrays.asList(upLoadDir.listFiles());
System.out.println("start upload");
InputStream stream = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8));
lanyingCloud.uploadFile(stream, base + "/a.txt");
modsList.forEach(file -> {
if(file.getName().endsWith(".wbp") || file.getName().endsWith(".txt")) {
try {
System.out.println("uploading " + file.getName());
InputStream stream1 = new FileInputStream(file);
String remotePath = base + "/" + getEncodeUrl(file.getName());
lanyingCloud.uploadFile(stream1, remotePath);
} catch (Exception e) {
e.printStackTrace();
}
}
});
return this;
}
private String getEncodeUrl(String s) {
try {
return URLEncoder.encode(s, "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "";
}
public static void main(String[] args) {
UploadToBlueHawkCloud.create().doUpload();
}
private String initString() {
return "test string, about 4KB";
}
}
Uploaded WebSites:
Shared problem linked: https://xn--9kq.xn--fx1at73c.com/index.php/s/2KbrqgBK4peKA8t