1414 * limitations under the License.
1515 */
1616
17+
1718import io .minio .MinioClient ;
1819import io .minio .PostPolicy ;
1920import io .minio .errors .ClientException ;
3334
3435public class PresignedPostPolicy {
3536 public static void main (String [] args ) throws IOException , XmlPullParserException , ClientException , NoSuchAlgorithmException , InvalidKeyException {
37+
38+ // Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
39+ // are dummy values, please replace them with original values.
3640 // Set s3 endpoint, region is calculated automatically.
3741 MinioClient s3Client = new MinioClient ("https://s3.amazonaws.com" , "YOUR-ACCESSKEYID" , "YOUR-SECRETACCESSKEY" );
3842
@@ -41,8 +45,8 @@ public static void main(String[] args) throws IOException, XmlPullParserExceptio
4145 date = date .plusMonths (1 ); // Expire in one month.
4246
4347 // set policy parameters.
44- policy .setKey ("objectName " );
45- policy .setBucket ("bucketName " );
48+ policy .setKey ("my-objectname " );
49+ policy .setBucket ("my-bucketname " );
4650 policy .setExpires (date );
4751 policy .setContentType ("image/png" );
4852
@@ -52,6 +56,6 @@ public static void main(String[] args) throws IOException, XmlPullParserExceptio
5256 for (Map .Entry <String , String > entry : formData .entrySet ()) {
5357 System .out .print (" -F " + entry .getKey () + "=" + entry .getValue ());
5458 }
55- System .out .print ("-F file=@/tmp/userpic.png https://s3.amazonaws.com/bucketName \n " );
59+ System .out .print ("-F file=@/tmp/userpic.png https://s3.amazonaws.com/my-bucketname \n " );
5660 }
5761}
0 commit comments