src/main/java/com/upplication/s3fs/util/S3Utils.java
public S3BasicFileAttributes toS3FileAttributes(S3ObjectSummary objectSummary, String key) {
        // parse the data to BasicFileAttributes.
        FileTime lastModifiedTime = null;
        if (objectSummary.getLastModified() != null) {
            lastModifiedTime = FileTime.from(objectSummary.getLastModified().getTime(), TimeUnit.MILLISECONDS);
        }
        long size = objectSummary.getSize();
        boolean directory = false;
        boolean regularFile = false;
        String resolvedKey = objectSummary.getKey();
        // check if is a directory and exists the key of this directory at amazon s3
        if (key.endsWith("/") && resolvedKey.equals(key) ||
                resolvedKey.equals(key + "/")) {
            directory = true;
        } else if (key.isEmpty()) { // is a bucket (no key)
            directory = true;
            resolvedKey = "/";
        } else if (!resolvedKey.equals(key) && resolvedKey.startsWith(key)) { // is a directory but not exists at amazon s3
            directory = true;
            // no metadata, we fake one
            size = 0;
            // delete extra part
            resolvedKey = key + "/";
        } else {
            regularFile = true;
        }
        return new S3BasicFileAttributes(resolvedKey, lastModifiedTime, size, directory, regularFile);
    }
/**
     * transform S3ObjectSummary to S3FileAttributes
     *
     * @param objectSummary S3ObjectSummary mandatory not null, the real objectSummary with
     *                      exactly the same key than the key param or the immediate descendant
     *                      if it is a virtual directory
     * @param key           String the real key that can be exactly equal than the objectSummary or
     * @return S3FileAttributes
     */
transform S3ObjectSummary to S3FileAttributes
@param objectSummary S3ObjectSummary mandatory not null, the real objectSummary with
exactly the same key than the key param or the immediate descendant
if it is a virtual directory
@param key           String the real key that can be exactly equal than the objectSummary or
@return S3FileAttributes
transform S3ObjectSummary to S3FileAttributes @param objectSummary S3ObjectSummary mandatory not null the real objectSummary with exactly the same key than the key param or the immediate descendant if it is a virtual directory @param key String the real key that can be exactly equal than the objectSummary or @return S3FileAttributes
public S3BasicFileAttributes toS3FileAttributes(S3ObjectSummary objectSummary, String key) {
        FileTime lastModifiedTime = null;
        if (objectSummary.getLastModified() != null) {
            lastModifiedTime = FileTime.from(objectSummary.getLastModified().getTime(), TimeUnit.MILLISECONDS);
        }
        long size = objectSummary.getSize();
        boolean directory = false;
        boolean regularFile = false;
        String resolvedKey = objectSummary.getKey();
        if (key.endsWith("/") && resolvedKey.equals(key) ||
                resolvedKey.equals(key + "/")) {
            directory = true;
        } else if (key.isEmpty()) { 
            directory = true;
            resolvedKey = "/";
        } else if (!resolvedKey.equals(key) && resolvedKey.startsWith(key)) { 
            directory = true;
            size = 0;
            resolvedKey = key + "/";
        } else {
            regularFile = true;
        }
        return new S3BasicFileAttributes(resolvedKey, lastModifiedTime, size, directory, regularFile);
    }
public S3BasicFileAttributes toS3FileAttributes ( S3ObjectSummary objectSummary , String key ) { FileTime lastModifiedTime = null ; if ( objectSummary . getLastModified ( ) != null ) { lastModifiedTime = FileTime . from ( objectSummary . getLastModified ( ) . getTime ( ) , TimeUnit . MILLISECONDS ) ; } long size = objectSummary . getSize ( ) ; boolean directory = false ; boolean regularFile = false ; String resolvedKey = objectSummary . getKey ( ) ; if ( key . endsWith ( "/" ) && resolvedKey . equals ( key ) || resolvedKey . equals ( key + "/" ) ) { directory = true ; } else if ( key . isEmpty ( ) ) { directory = true ; resolvedKey = "/" ; } else if ( ! resolvedKey . equals ( key ) && resolvedKey . startsWith ( key ) ) { directory = true ; size = 0 ; resolvedKey = key + "/" ; } else { regularFile = true ; } return new S3BasicFileAttributes ( resolvedKey , lastModifiedTime , size , directory , regularFile ) ; }
transform S3ObjectSummary to S3FileAttributes
 @param objectSummary S3ObjectSummary mandatory not null, the real objectSummary with
                      exactly the same key than the key param or the immediate descendant
                      if it is a virtual directory
 @param key           String the real key that can be exactly equal than the objectSummary or
 @return S3FileAttributes
transform S3ObjectSummary to S3FileAttributes @param objectSummary S3ObjectSummary mandatory not null the real objectSummary with exactly the same key than the key param or the immediate descendant if it is a virtual directory @param key String the real key that can be exactly equal than the objectSummary or @return S3FileAttributes
// parse the data to BasicFileAttributes. // check if is a directory and exists the key of this directory at amazon s3 // is a bucket (no key) // is a directory but not exists at amazon s3 // no metadata, we fake one // delete extra part