I am using https://github.com/GoogleCloudPlatform/spring-cloud-gcp/tree/main/spring-cloud-gcp-storage
I found that folders created through the cloud dashboard have a content-type of text/plain, while ones created through the API like this don’t:
com.google.cloud.storage.Storage#create(
BlobInfo.newBuilder(
bucketName,
"gcpbug/api-folder/test.txt"
),
"Hello World!".getBytes()
);
additionally, going to the ones created manually in the dashboard with a trailing slash do not result in a 404, while the ones that are created with the API do actually result in a 404:
The URLs:
https://cdn.carbonhost.cloud/gcpbug/manual-folder/
https://cdn.carbonhost.cloud/gcpbug/api-folder/
public JsonArray getFiles(UserDetailsImpl user,String folder) {
String fullFolderPath = user.getId() + (folder == null || folder.isEmpty() ? "/" : folder);
if (!fullFolderPath.endsWith("/")) fullFolderPath += "/";
System.out.println("Folder Path: " + fullFolderPath);
Page<Blob> blobs = storage.list(bucketName, Storage.BlobListOption.prefix(fullFolderPath), Storage.BlobListOption.currentDirectory());
JsonArray arr = new JsonArray();
for (Blob blob : blobs.iterateAll()) {
System.out.println("Blob: " + blob);
JsonObject obj = new JsonObject();
String fullPath = blob.getName();
if (fullPath.endsWith("/")) {
fullPath = fullPath.substring(0, fullPath.length() - 1);
}
fullPath = fullPath.substring(user.getId().length() + 1);
//get last part of path
String fileName = fullPath.substring(fullPath.lastIndexOf("/") + 1);
obj.addProperty("name", fileName);
obj.addProperty("fullPath", fullPath);
obj.addProperty("size", blob.getSize());
obj.addProperty("type", blob.getContentType());
obj.addProperty("created", blob.getCreateTime());
obj.addProperty("modified", blob.getUpdateTime());
obj.addProperty("directory", blob.isDirectory());
obj.addProperty("url","https://" + blob.getBucket() + "/" + blob.getName());
arr.add(obj);
}
return arr;
}
Using this to list all the files in a manually-created folder includes itself in the results:
while listing all the files in a folder created with the API, it does not include itself.
the blobs (folder123 created in the dashboard and folder 1234 created with the API):
Is this a bug and can anyone else reproduce this? Or am I doing something wrong?





