Upload file to S3 from jenkin script pipeline

I need to upload a file from jenkin to S3 bucket. I need to do this in the scripted pipeline area.I tried as below.

stage('Upload') {

        dir('path/to/your/project/workspace'){

            pwd(); //Log current directory

            withAWS(region:'yourS3Region',credentials:'yourIDfromStep2') {

                 def identity=awsIdentity();//Log AWS credentials

                // Upload files from working directory 'dist' in your project workspace
                s3Upload(bucket:"yourBucketName", workingDir:'dist', includePathPattern:'**/*');
            }

        };
    }