Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
49 lines (39 loc) · 1.82 KB

File metadata and controls

49 lines (39 loc) · 1.82 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import javax.crypto.KeyGenerator;
import org.xmlpull.v1.XmlPullParserException;
import io.minio.MinioClient;
import io.minio.ServerSideEncryption;
import io.minio.errors.MinioException;
public class PutGetObjectEncryptedFile {
/**
* MinioClient.putObject() and MinioClient.getObject() to a file example for SSE_C.
*/
public static void main(String[] args)
throws NoSuchAlgorithmException, IOException, InvalidKeyException, XmlPullParserException {
try {
/* play.min.io for test and development. */
MinioClient minioClient = new MinioClient("https://play.min.io:9000", "Q3AM3UQ867SPQQA43P2F",
"zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG");
//* Amazon S3: */
// MinioClient minioClient = new MinioClient("https://s3.amazonaws.com", "YOUR-ACCESSKEYID",
// "YOUR-SECRETACCESSKEY");
String objectName = "my-objectname";
String bucketName = "my-bucketname";
String inputfile = "my-inputfile";
String outputfile = "my-outputfile";
// Generate a new 256 bit AES key - This key must be remembered by the client.
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
keyGen.init(256);
// To test SSE-C
ServerSideEncryption sse = ServerSideEncryption.withCustomerKey(keyGen.generateKey());
minioClient.putObject(bucketName, objectName, sse, inputfile);
System.out.println("my-objectname is encrypted and uploaded successfully.");
minioClient.getObject(bucketName, objectName, sse, outputfile);
System.out.println("Content of my-objectname saved to my-outputfile ");
} catch (MinioException e) {
System.out.println("Error occurred: " + e);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.