Reputation: 1
We are already using spring content with content stores for JpaContentStore and FileContentStore. Now we are adding support for S3ContentStore but unfortunately we miss one important thing when uploading a file via setContent: a parameter for the storage class.
I have reads lots of things but I don't know how do get a solution for it. One of my ideas was to create a new MyS3ContentStore which simply extends S3ContentStore with an new method like
@LockParticipant
E setContent(E entity, InputStream content, StorageClass storageClass);
I have also created an implementation for that like that
@Transactional
public class MyS3ContentStoreImpl<E, CID extends Serializable> extends DefaultS3StoreImpl<E, CID>
implements MyS3ContentStore<E, CID> {
public AMyS3ContentStoreImpl(ApplicationContext context, ResourceLoader loader, MappingContext mappingContext, PlacementService placementService, S3Client client, MultiTenantS3ClientProvider provider) {
super(context, loader, mappingContext, placementService, client, provider);
}
@Override
public E setContent(E entity, InputStream content, StorageClass storageClass) {
return setContent(entity, content);
}
}
I also read that I must use @EnableS3Stores with defines basePackages telling where to find my classes.
Finally I have create a store for my concrete entity ArchivedFile:
@Repository
public interface MyS3Store extends MyS3ContentStore<ArchivedFile, UUID> {}
I tried several things but I cant get i working. Depending on what I do my classes are not found or I get an error because more than one bean with name 'myS3Store#StoreFragments' is created. As I did lots of things I can't tell here exactly what caused what.
So my question is:
What is the best way to achieve what I want? Are there some conventions I muss follow? Any other things I could miss? I have checked f.e. the azure example but this is a complete new Store and there are lots of classes in different packages and I´m not sure if I need all that classes and if I have to follow some packaging rules.
Upvotes: 0
Views: 24
Reputation: 2479
By storage classes are you referring to these storage classes?
If so then the S3 module does not support specifying the storage class.
You could provide your own implementation of teh S3ContentStore (by specifying storeFactoryBeanClass
on the @EnableS3Stores
annotation. Provide a factory bean that instantiates your own implementation of the ContentStore
interface.
But this would make a great feature request so I would recommend raising an Issue against the project. Not very familiar with storage classes but if, from an API, perspective it is just a setting you pass when storing the object then it would be simple to add.
HTH
Upvotes: 0