Tuesday, 5 May 2020

download file instead of open in browser

 $s3Client = new S3Client(array(
           'version'     => 'latest',
           'region'      => env('lambda_region'),
           'credentials' => array(
               'key'    => env('s3_accessKey'),
               'secret' => env('s3_secretKey')
           )
       ));
       $result =  $s3Client->putObject(array(
           'Bucket'     => env('s3_bucket'),
           'Key'        => $fileName,
           'SourceFile' => $localfilePath,
           'ContentType' =>'image/png',
           'ContentDisposition' => 'attachment',
           'ACL'          => 'public-read'
       ));
     return $result['ObjectURL'];
   }

Friday, 1 May 2020

hibernet dependency pom file

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.doctorbest</groupId>
<artifactId>myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myapp</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
        <profile>
            <id>jar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <artifact-packaging>jar</artifact-packaging>               
            </properties>
             <dependencies>
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>                   
                </dependency>
            </dependencies>
        </profile>
        </profiles>

</project>

Thursday, 5 March 2020

mysql concat two field with null

https://dba.stackexchange.com/questions/110949/how-to-exclude-null-values-inside-concat-mysql


MySQL concat  return null if one of the concated fields is null .
to avoid this issue use
CONCAT_WS(" ","field_one","field_two","and so on")

Wednesday, 4 March 2020

select if condition in mysql

https://stackoverflow.com/questions/31962449/mysql-select-column-if-not-null-only

SELECT IFNULL(firstname,'') AS firstname, 
IFNULL(lastname,'') AS lastname, 
IFNULL(age,'') AS age, 
IFNULL(gender,'') AS gender 
FROM persons WHERE id = 1;