Using Uploadify to POST Directly to Amazon S3

前端 未结 3 1716
陌清茗
陌清茗 2021-01-18 11:19

Can anyone tell me how to use Uploadify to upload directly to Amazon S3?

My code is as follows:

$(\'#fileInput\').uploadify({
  \'fileDataName\' : \'         


        
3条回答
  •  梦毁少年i
    2021-01-18 12:17

    this is the java code for saving image into s3cloud. add this code into your uploadscript file (like uploadify.php) you will have your own uploadify script file.

    AWSCredentials credentials = new AWSCredentials(_ACCESS_KEY, _SECRET_KEY);

        log.info("oovfilepath : " + oovfilepath);
        log.info("name : " + name);
        S3Service s3Service = new RestS3Service(credentials);
        S3Bucket s3Bucket = s3Service.createBucket(_BUCKET_NAME);
        AccessControlList bucketAcl = s3Service.getBucketAcl(s3Bucket);
        bucketAcl.grantPermission(GroupGrantee.ALL_USERS,
                Permission.PERMISSION_READ);
    
        InputStream input = new FileInputStream(oovfilepath);
    
        S3Object s3Object = new S3Object(s3Bucket, name);
        log.info("s3Object:" + s3Object);
    
        s3Object.setAcl(bucketAcl);
        s3Object.setDataInputStream(input);
    
        log.info("s3Object:" + s3Object);
    
        s3Service.putObject(s3Bucket, s3Object);
    

提交回复
热议问题