public void upload()

in experimental/aws-lambda-java-profiler/extension/src/main/java/com/amazonaws/services/lambda/extension/S3Manager.java [33:58]


    public void upload(String fileName, boolean isShutDownEvent) {
        try {
            final String suffix = isShutDownEvent ? "shutdown" : fileName;
            final String key = buildKey(FUNCTION_NAME, fileName);
            Logger.debug("uploading profile to key = " + key);
            PutObjectRequest putObjectRequest = PutObjectRequest.builder()
                    .bucket(bucketName)
                    .key(key)
                    .build();
            File file = new File(String.format("/tmp/profiling-data-%s.html", suffix));
            if (file.exists()) {
                Logger.debug("file size is " + file.length());
                RequestBody requestBody = RequestBody.fromFile(file);
                PutObjectResponse response = s3Client.putObject(putObjectRequest, requestBody);
                Logger.debug("profile uploaded successfully. ETag: " + response.eTag());
                if(file.delete()) {
                    Logger.debug("file deleted");
                }
            } else {
                throw new IllegalArgumentException("could not find the profile to upload");
            }
        } catch (Exception e) {
            Logger.error("could not upload the profile");
            e.printStackTrace();
        }
    }