<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aryan Dwivedi</title>
    <description>The latest articles on DEV Community by Aryan Dwivedi (@rnd2002).</description>
    <link>https://dev.to/rnd2002</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1168818%2Fa90483b3-bc15-4916-a523-c36b3e97cd57.png</url>
      <title>DEV Community: Aryan Dwivedi</title>
      <link>https://dev.to/rnd2002</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rnd2002"/>
    <language>en</language>
    <item>
      <title>Wanted to access url based on user role in my app but there seems to be some problem</title>
      <dc:creator>Aryan Dwivedi</dc:creator>
      <pubDate>Fri, 27 Oct 2023 15:15:36 +0000</pubDate>
      <link>https://dev.to/rnd2002/wanted-to-access-url-based-on-user-role-in-my-app-but-there-seems-to-be-some-problem-268j</link>
      <guid>https://dev.to/rnd2002/wanted-to-access-url-based-on-user-role-in-my-app-but-there-seems-to-be-some-problem-268j</guid>
      <description>&lt;p&gt;i have addedd authorization token in react and ROLE_ADMIN is role &lt;strong&gt;stored in database&lt;br&gt;
you cxan review my code at github&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;a href="https://github.com/RND2002/quizSpringboot"&gt;https://github.com/RND2002/quizSpringboot&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;a href="https://github.com/RND2002/quizReact"&gt;https://github.com/RND2002/quizReact&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
Please help me to complete this my deadline is nere&lt;/p&gt;

&lt;p&gt;You can review my code at -&amp;gt;&lt;a href="https://github.com/RND2002/quizSpringboot"&gt;https://github.com/RND2002/quizSpringboot&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you can review my react code at-&amp;gt;&lt;a href="https://github.com/RND2002/quizReact"&gt;https://github.com/RND2002/quizReact&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;//error in react console&lt;/p&gt;

&lt;p&gt;AuthContext.js:32 intercepting and adding a token&lt;br&gt;
createQuiz:1 Access to XMLHttpRequest at '&lt;a href="http://localhost:8080/quiz/create?category=a&amp;amp;num=1&amp;amp;title=hndth"&gt;http://localhost:8080/quiz/create?category=a&amp;amp;num=1&amp;amp;title=hndth&lt;/a&gt;' from origin '&lt;a href="http://localhost:3000"&gt;http://localhost:3000&lt;/a&gt;' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.&lt;br&gt;
QuestionCreation.jsx:40 AxiosError {message: 'Network Error', name: 'AxiosError', code: 'ERR_NETWORK', config: {…}, request: XMLHttpRequest, …}&lt;br&gt;
xhr.js:256 &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   POST http://localhost:8080/quiz/create?category=a&amp;amp;num=1&amp;amp;title=hndth net::ERR_FAILED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;//error in sprinig boot log&lt;br&gt;
 Authenticated user&lt;br&gt;
2023-10-27T20:25:20.725+05:30 DEBUG 4812 --- [nio-8080-exec-1] o.s.s.w.a.&lt;a href="http://www.BasicAuthenticationFilter"&gt;www.BasicAuthenticationFilter&lt;/a&gt;  : Set SecurityContextHolder to UsernamePasswordAuthenticationToken [Principal=org.springframework.security.core.userdetails.User [Username=ranga2, Password=[PROTECTED], Enabled=true, AccountNonExpired=true, credentialsNonExpired=true, AccountNonLocked=true, Granted Authorities=[ROLE_ADMIN]], Credentials=[PROTECTED], Authenticated=true, Details=WebAuthenticationDetails [RemoteIpAddress=0:0:0:0:0:0:0:1, SessionId=null], Granted Authorities=[ROLE_ADMIN]]&lt;br&gt;
2023-10-27T20:25:20.745+05:30 DEBUG 4812 --- [nio-8080-exec-1] o.s.security.web.FilterChainProxy        : Secured GET /basicauth&lt;br&gt;
2023-10-27T20:25:39.848+05:30 DEBUG 4812 --- [nio-8080-exec-2] o.s.security.web.FilterChainProxy        : Securing OPTIONS /quiz/create?category=a&amp;amp;num=1&amp;amp;title=hndth&lt;br&gt;
2023-10-27T20:25:39.849+05:30 DEBUG 4812 --- [nio-8080-exec-2] o.s.s.w.a.AnonymousAuthenticationFilter  : Set SecurityContextHolder to anonymous SecurityContext&lt;br&gt;
2023-10-27T20:25:39.853+05:30 DEBUG 4812 --- [nio-8080-exec-2] s.w.a.DelegatingAuthenticationEntryPoint : Trying to match using RequestHeaderRequestMatcher [expectedHeaderName=X-Requested-With, expectedHeaderValue=XMLHttpRequest]&lt;br&gt;
2023-10-27T20:25:39.854+05:30 DEBUG 4812 --- [nio-8080-exec-2] s.w.a.DelegatingAuthenticationEntryPoint : No match found. Using default entry point org.springframework.security.web.authentication.&lt;a href="http://www.BasicAuthenticationEntryPoint@3c0dea36"&gt;www.BasicAuthenticationEntryPoint@3c0dea36&lt;/a&gt;&lt;br&gt;
2023-10-27T20:25:39.860+05:30 DEBUG 4812 --- [nio-8080-exec-2] o.s.security.web.FilterChainProxy        : Securing OPTIONS /error?category=a&amp;amp;num=1&amp;amp;title=hndth&lt;br&gt;
2023-10-27T20:25:39.865+05:30 DEBUG 4812 --- [nio-8080-exec-2] o.s.s.w.a.AnonymousAuthenticationFilter  : Set SecurityContextHolder to anonymous SecurityContext&lt;br&gt;
2023-10-27T20:25:39.865+05:30 DEBUG 4812 --- [nio-8080-exec-2] s.w.a.DelegatingAuthenticationEntryPoint : Trying to match using RequestHeaderRequestMatcher [expectedHeaderName=X-Requested-With, expectedHeaderValue=XMLHttpRequest]&lt;br&gt;
2023-10-27T20:25:39.866+05:30 DEBUG 4812 --- [nio-8080-exec-2] s.w.a.DelegatingAuthen****&lt;/p&gt;

</description>
      <category>sprinboot</category>
      <category>react</category>
      <category>springsecurity</category>
      <category>javascript</category>
    </item>
    <item>
      <title>React js issue</title>
      <dc:creator>Aryan Dwivedi</dc:creator>
      <pubDate>Thu, 28 Sep 2023 14:40:58 +0000</pubDate>
      <link>https://dev.to/rnd2002/react-js-issue-2l8o</link>
      <guid>https://dev.to/rnd2002/react-js-issue-2l8o</guid>
      <description>&lt;p&gt;wanted to retreive data by the param district but array received is empty but when i am receiving all data from database it is coming fine&lt;/p&gt;

&lt;p&gt;url i am trying in react is localhost:3000/dashboard/varanasi and it is giving emply array in response but in my localhost:8080/public/get/varanasi it is working fine&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/blue-bush-lrnhpk?file=/src/components/CommonDashBoard.jsx"&gt;https://codesandbox.io/s/blue-bush-lrnhpk?file=/src/components/CommonDashBoard.jsx&lt;/a&gt; //source code here &lt;/p&gt;

</description>
    </item>
    <item>
      <title>spring boot file not found error</title>
      <dc:creator>Aryan Dwivedi</dc:creator>
      <pubDate>Sun, 24 Sep 2023 08:58:56 +0000</pubDate>
      <link>https://dev.to/rnd2002/spring-boot-file-not-found-error-4pad</link>
      <guid>https://dev.to/rnd2002/spring-boot-file-not-found-error-4pad</guid>
      <description>&lt;p&gt;I was trying to upload image to my database through my spring boot app &lt;br&gt;
//This was my code to handle the image and data&lt;br&gt;
public ResponseEntity addProduct( Product product, MultipartFile file) {&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Authentication authentication= SecurityContextHolder.getContext().getAuthentication();

    String userName= authentication.getName();
    Users admin = userRepository.findByUsername(userName);

    try {
        if (!file.isEmpty()) {
            byte[] imageData = file.getBytes();
            product.setImage(imageData);
            productRepository.save(product);
            ProductOwnerShip productOwnerShip=new ProductOwnerShip();
            productOwnerShip.setProduct(product);
            productOwnerShip.setUser(admin);
            productOwnerShipRepository.save(productOwnerShip);
        } else {
            return new ResponseEntity&amp;lt;&amp;gt;("Error: No image file uploaded", HttpStatus.BAD_REQUEST);
        }

        // Process and save the product with the image in your database



        return new ResponseEntity&amp;lt;&amp;gt;("Product added successfully", HttpStatus.OK);
    } catch (IOException e) {
        e.printStackTrace();
        return new ResponseEntity&amp;lt;&amp;gt;("Error uploading image", HttpStatus.INTERNAL_SERVER_ERROR);
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;//error from spring boot&lt;br&gt;
2023-09-24 14:21:38.387  WARN 10344 --- [nio-8080-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object 'product' on field 'image': rejected value [org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile@52f1e52b]; codes [typeMismatch.product.image,typeMismatch.image,typeMismatch.[B,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [product.image,image]; arguments []; default message [image]]; default message [Failed to convert property value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'byte[]' for property 'image'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'byte' for property 'image[0]': PropertyEditor [org.springframework.beans.propertyeditors.CustomNumberEditor] returned inappropriate value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile']]&lt;br&gt;
2023-09-24 14:21:38.488 ERROR 10344 --- [nio-8080-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] threw exception&lt;/p&gt;

&lt;p&gt;java.io.FileNotFoundException: C:\Users\aryan\AppData\Local\Temp\tomcat.8080.15562901959233805749\work\Tomcat\localhost\ROOT\upload_72b1efba_2385_4ffe_9115_ee9129d61d39_00000020.tmp (The system cannot find the file specified)&lt;br&gt;
    at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]&lt;br&gt;
    at java.base/java.io.FileInputStream.open(FileInputStream.java:219) ~[na:na]&lt;br&gt;
    at java.base/java.io.FileInputStream.(FileInputStream.java:158) ~[na:na]&lt;/p&gt;

&lt;p&gt;plz someone help me I am new to spring boot&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>postman</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
