commit
ce379a652d
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="lib" path="lib/minio-8.4.5-all.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>TestWordToPDF</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,12 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,44 @@
|
|||||||
|
package com.connor.uploadfile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import io.minio.GetPresignedObjectUrlArgs;
|
||||||
|
import io.minio.MinioClient;
|
||||||
|
import io.minio.ObjectWriteResponse;
|
||||||
|
import io.minio.PutObjectArgs;
|
||||||
|
import io.minio.http.Method;
|
||||||
|
|
||||||
|
public class MinioUtil {
|
||||||
|
private static final String ENDPOINT = "http://10.128.11.20:9000";
|
||||||
|
private static final String ACCESS_KEY = "plmichi";
|
||||||
|
private static final String SECRET_KEY = "D&sV#u4C";
|
||||||
|
|
||||||
|
private MinioClient minioClient;
|
||||||
|
|
||||||
|
public MinioUtil() {
|
||||||
|
minioClient = MinioClient.builder().endpoint(ENDPOINT).credentials(ACCESS_KEY, SECRET_KEY).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String sendFileToMinio(File file, String minioObj) throws Exception {
|
||||||
|
|
||||||
|
InputStream in = new FileInputStream(file);
|
||||||
|
// MinioClient client = MinioClient.builder().endpoint("http://10.128.11.20:9000")
|
||||||
|
// .credentials("plmichi", "D&sV#u4C").build();
|
||||||
|
|
||||||
|
PutObjectArgs build = PutObjectArgs.builder().bucket("plmichi").object("SapBomLog/" + file.getName())
|
||||||
|
.stream(in, in.available(), -1).build();
|
||||||
|
|
||||||
|
minioClient.putObject(build);
|
||||||
|
|
||||||
|
// GetPresignedObjectUrlArgs urlBuild = GetPresignedObjectUrlArgs.builder().bucket("plmichi").object(minioObj)
|
||||||
|
// .method(Method.GET).build();
|
||||||
|
//
|
||||||
|
// String presignedObjectUrl = minioClient.getPresignedObjectUrl(urlBuild);
|
||||||
|
// System.out.println(presignedObjectUrl);
|
||||||
|
|
||||||
|
return "";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.connor.uploadfile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||||
|
|
||||||
|
import io.minio.GetPresignedObjectUrlArgs;
|
||||||
|
import io.minio.MinioClient;
|
||||||
|
import io.minio.ObjectWriteResponse;
|
||||||
|
import io.minio.PutObjectArgs;
|
||||||
|
import io.minio.UploadObjectArgs;
|
||||||
|
import io.minio.http.Method;
|
||||||
|
|
||||||
|
public class UploadFile {
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
String filePath = args[0];//"D:\\1.txt";//
|
||||||
|
// InputStream in = null;
|
||||||
|
try {
|
||||||
|
File file = new File(filePath);
|
||||||
|
String sendFileToMinio = sendFileToMinio(file, "SapBomLog/" + file.getName());
|
||||||
|
System.out.println(sendFileToMinio);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.exit(0);
|
||||||
|
// System.out.println("11111");
|
||||||
|
// return;
|
||||||
|
}
|
||||||
|
public static String sendFileToMinio(File file, String minioObj) throws Exception {
|
||||||
|
|
||||||
|
// InputStream in = new FileInputStream(file);
|
||||||
|
MinioClient client = MinioClient.builder().endpoint("http://10.128.11.20:9000")
|
||||||
|
.credentials("plmichi", "D&sV#u4C").build();
|
||||||
|
|
||||||
|
// PutObjectArgs build = PutObjectArgs.builder().bucket("plmichi").object("SapBomLog/" + file.getName())
|
||||||
|
// .stream(in, in.available(), -1).build();
|
||||||
|
UploadObjectArgs build2 = UploadObjectArgs.builder()
|
||||||
|
.bucket("plmichi")
|
||||||
|
.object("SapBomLog/" + file.getName())
|
||||||
|
.filename(file.getPath())
|
||||||
|
.build();
|
||||||
|
client.uploadObject(build2);
|
||||||
|
GetPresignedObjectUrlArgs urlBuild = GetPresignedObjectUrlArgs.builder().bucket("plmichi").object(minioObj)
|
||||||
|
.method(Method.GET).build();
|
||||||
|
// System.out.println("1");
|
||||||
|
String presignedObjectUrl = client.getPresignedObjectUrl(urlBuild);
|
||||||
|
// System.out.println(presignedObjectUrl);
|
||||||
|
|
||||||
|
return presignedObjectUrl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue