customize file location in spring content
up vote
0
down vote
favorite
I am working with spring content i have an entity that holds pictures and videos so i want to all videos and pictures to be stored in this directory home/user/photo_video_myram
photo_video_myram is folder i want all files to be stored there but im not sure how to go about it with spring content
according to the documentation i can create beans like this
@Bean
File filesystemRoot() {
try {
return Files.createTempDirectory("photo_video_myram").toFile();
} catch (IOException io) {}
return null;
}
@Bean
FileSystemResourceLoader fileSystemResourceLoader() {
return new FileSystemResourceLoader(filesystemRoot().getAbsolutePath());
}
when i run the app it shows no error even when i upload files but they are not stored in the expected folder i also tried to full dir home/user/photo_video_myram but with that i get cannot create bean filesystemroot
can i get an explanation on how storing files work and how i can create my own customized location where all images and videos will be stored
I also tried this
@Bean
File filesystemRoot() {
try {
return Files.createDirectory(Paths.get("/home/user/photo_video_myram")).toFile();
} catch (IOException io) {}
return null;
}
but i got
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentEntityRestController' defined in URL [jar:file:/home/user/.m2/repository/com/github/paulcwarren/spring-content-rest/0.4.0/spring-content-rest-0.4.0.jar!/internal/org/springframework/content/rest/controllers/ContentEntityRestController.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentStoreService': Unsatisfied dependency expressed through method 'setFactories' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.9.RELEASE.jar
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
:5.0.9.RELEASE]
at or
spring spring-boot
add a comment |
up vote
0
down vote
favorite
I am working with spring content i have an entity that holds pictures and videos so i want to all videos and pictures to be stored in this directory home/user/photo_video_myram
photo_video_myram is folder i want all files to be stored there but im not sure how to go about it with spring content
according to the documentation i can create beans like this
@Bean
File filesystemRoot() {
try {
return Files.createTempDirectory("photo_video_myram").toFile();
} catch (IOException io) {}
return null;
}
@Bean
FileSystemResourceLoader fileSystemResourceLoader() {
return new FileSystemResourceLoader(filesystemRoot().getAbsolutePath());
}
when i run the app it shows no error even when i upload files but they are not stored in the expected folder i also tried to full dir home/user/photo_video_myram but with that i get cannot create bean filesystemroot
can i get an explanation on how storing files work and how i can create my own customized location where all images and videos will be stored
I also tried this
@Bean
File filesystemRoot() {
try {
return Files.createDirectory(Paths.get("/home/user/photo_video_myram")).toFile();
} catch (IOException io) {}
return null;
}
but i got
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentEntityRestController' defined in URL [jar:file:/home/user/.m2/repository/com/github/paulcwarren/spring-content-rest/0.4.0/spring-content-rest-0.4.0.jar!/internal/org/springframework/content/rest/controllers/ContentEntityRestController.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentStoreService': Unsatisfied dependency expressed through method 'setFactories' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.9.RELEASE.jar
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
:5.0.9.RELEASE]
at or
spring spring-boot
I think your immediate problem is that you're hitting thereturn null
on your IOException handler, and so Spring context init blows up.
– moilejter
Nov 11 at 19:14
try setting below property in your application.properties:spring.servlet.multipart.location=/home/user/...
– Puneet
Nov 12 at 0:51
nice idea @Puneet please explain how this works and how i can attach path to each file to a file "localpath" in my entity photo
– valik
Nov 12 at 19:29
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working with spring content i have an entity that holds pictures and videos so i want to all videos and pictures to be stored in this directory home/user/photo_video_myram
photo_video_myram is folder i want all files to be stored there but im not sure how to go about it with spring content
according to the documentation i can create beans like this
@Bean
File filesystemRoot() {
try {
return Files.createTempDirectory("photo_video_myram").toFile();
} catch (IOException io) {}
return null;
}
@Bean
FileSystemResourceLoader fileSystemResourceLoader() {
return new FileSystemResourceLoader(filesystemRoot().getAbsolutePath());
}
when i run the app it shows no error even when i upload files but they are not stored in the expected folder i also tried to full dir home/user/photo_video_myram but with that i get cannot create bean filesystemroot
can i get an explanation on how storing files work and how i can create my own customized location where all images and videos will be stored
I also tried this
@Bean
File filesystemRoot() {
try {
return Files.createDirectory(Paths.get("/home/user/photo_video_myram")).toFile();
} catch (IOException io) {}
return null;
}
but i got
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentEntityRestController' defined in URL [jar:file:/home/user/.m2/repository/com/github/paulcwarren/spring-content-rest/0.4.0/spring-content-rest-0.4.0.jar!/internal/org/springframework/content/rest/controllers/ContentEntityRestController.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentStoreService': Unsatisfied dependency expressed through method 'setFactories' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.9.RELEASE.jar
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
:5.0.9.RELEASE]
at or
spring spring-boot
I am working with spring content i have an entity that holds pictures and videos so i want to all videos and pictures to be stored in this directory home/user/photo_video_myram
photo_video_myram is folder i want all files to be stored there but im not sure how to go about it with spring content
according to the documentation i can create beans like this
@Bean
File filesystemRoot() {
try {
return Files.createTempDirectory("photo_video_myram").toFile();
} catch (IOException io) {}
return null;
}
@Bean
FileSystemResourceLoader fileSystemResourceLoader() {
return new FileSystemResourceLoader(filesystemRoot().getAbsolutePath());
}
when i run the app it shows no error even when i upload files but they are not stored in the expected folder i also tried to full dir home/user/photo_video_myram but with that i get cannot create bean filesystemroot
can i get an explanation on how storing files work and how i can create my own customized location where all images and videos will be stored
I also tried this
@Bean
File filesystemRoot() {
try {
return Files.createDirectory(Paths.get("/home/user/photo_video_myram")).toFile();
} catch (IOException io) {}
return null;
}
but i got
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentEntityRestController' defined in URL [jar:file:/home/user/.m2/repository/com/github/paulcwarren/spring-content-rest/0.4.0/spring-content-rest-0.4.0.jar!/internal/org/springframework/content/rest/controllers/ContentEntityRestController.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contentStoreService': Unsatisfied dependency expressed through method 'setFactories' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.9.RELEASE.jar
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileContentStore': Unsatisfied dependency expressed through field 'loader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileSystemResourceLoader' defined in class path resource [gettingstarted/Config.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.content.fs.io.FileSystemResourceLoader]: Factory method 'fileSystemResourceLoader' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
:5.0.9.RELEASE]
at or
spring spring-boot
spring spring-boot
edited Nov 11 at 17:31
asked Nov 11 at 17:00
valik
466216
466216
I think your immediate problem is that you're hitting thereturn null
on your IOException handler, and so Spring context init blows up.
– moilejter
Nov 11 at 19:14
try setting below property in your application.properties:spring.servlet.multipart.location=/home/user/...
– Puneet
Nov 12 at 0:51
nice idea @Puneet please explain how this works and how i can attach path to each file to a file "localpath" in my entity photo
– valik
Nov 12 at 19:29
add a comment |
I think your immediate problem is that you're hitting thereturn null
on your IOException handler, and so Spring context init blows up.
– moilejter
Nov 11 at 19:14
try setting below property in your application.properties:spring.servlet.multipart.location=/home/user/...
– Puneet
Nov 12 at 0:51
nice idea @Puneet please explain how this works and how i can attach path to each file to a file "localpath" in my entity photo
– valik
Nov 12 at 19:29
I think your immediate problem is that you're hitting the
return null
on your IOException handler, and so Spring context init blows up.– moilejter
Nov 11 at 19:14
I think your immediate problem is that you're hitting the
return null
on your IOException handler, and so Spring context init blows up.– moilejter
Nov 11 at 19:14
try setting below property in your application.properties:spring.servlet.multipart.location=/home/user/...
– Puneet
Nov 12 at 0:51
try setting below property in your application.properties:spring.servlet.multipart.location=/home/user/...
– Puneet
Nov 12 at 0:51
nice idea @Puneet please explain how this works and how i can attach path to each file to a file "localpath" in my entity photo
– valik
Nov 12 at 19:29
nice idea @Puneet please explain how this works and how i can attach path to each file to a file "localpath" in my entity photo
– valik
Nov 12 at 19:29
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251069%2fcustomize-file-location-in-spring-content%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think your immediate problem is that you're hitting the
return null
on your IOException handler, and so Spring context init blows up.– moilejter
Nov 11 at 19:14
try setting below property in your application.properties:spring.servlet.multipart.location=/home/user/...
– Puneet
Nov 12 at 0:51
nice idea @Puneet please explain how this works and how i can attach path to each file to a file "localpath" in my entity photo
– valik
Nov 12 at 19:29