Java 类com.amazonaws.services.s3.model.ProgressListener 实例源码

项目:upman    文件:S3Uploader.java   
public static void uploadToS3(TransferManager transferManager, final File file, final FileProgressListener fileProgressListener) throws InterruptedException {
    PutObjectRequest putObjectRequest = new PutObjectRequest("car-classifieds", file.getName(), file)
            .withCannedAcl(CannedAccessControlList.PublicRead);
    final Upload upload = transferManager.upload(putObjectRequest);
    upload.addProgressListener(new ProgressListener() {
        @Override
        public void progressChanged(ProgressEvent progressEvent) {
            fileProgressListener.onProgressChanged(progressEvent.getBytesTransferred());
            if (progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) {
                fileProgressListener.onCompleteUpload();
            }
            if (progressEvent.getEventCode() == com.amazonaws.event.ProgressEvent.STARTED_EVENT_CODE) {
                fileProgressListener.onStartUpload();
            }
            if (progressEvent.getEventCode() == com.amazonaws.event.ProgressEvent.FAILED_EVENT_CODE) {
                fileProgressListener.onFailedUpload();
            }
        }
    });
}
项目:upman    文件:S3Uploader.java   
public static void uploadToS3(TransferManager transferManager, final File file) throws InterruptedException {
    PutObjectRequest putObjectRequest = new PutObjectRequest("car-classifieds", file.getName(), file)
            .withCannedAcl(CannedAccessControlList.PublicRead);
    final Upload upload = transferManager.upload(putObjectRequest);
    upload.addProgressListener(new ProgressListener() {
        @Override
        public void progressChanged(ProgressEvent progressEvent) {
            if (progressEvent.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) {

            }
        }
    });
}
项目:vocefiscal-android    文件:AWSFiscalizacaoUpload.java   
public AWSFiscalizacaoUpload(Context context,OnFiscalizacaoUploadS3PostExecuteListener listener,Fiscalizacao fiscalizacao,Integer sleep)
{
    super(context);

    this.listener = listener;

    this.fiscalizacao = fiscalizacao;

    this.sleep = sleep;

    municipalities = Municipalities.getInstance(context);

    mStatus = Status.IN_PROGRESS;

    progressListener = new ProgressListener() 
    {
        @Override
        public void progressChanged(ProgressEvent event) 
        { 
            if(event.getEventCode() == ProgressEvent.COMPLETED_EVENT_CODE) 
            {
                mStatus = Status.COMPLETED;                 

                AWSFiscalizacaoUpload.this.listener.finishedFiscalizacaoUploadS3ComResultado(AWSFiscalizacaoUpload.this.fiscalizacao.getIdFiscalizacao());

            }else if(event.getEventCode() == ProgressEvent.FAILED_EVENT_CODE) 
            {
                mStatus = Status.CANCELED;

                if(mUpload != null) 
                {
                    mUpload.abort();
                }

                AWSFiscalizacaoUpload.this.listener.finishedFiscalizacaoUploadS3ComError(AWSFiscalizacaoUpload.this.fiscalizacao.getIdFiscalizacao());
            }
        }
    };
}