// Path: lolibox-server/src/main/java/io/loli/box/entity/User.java
// @Entity
// @Table(name = "user_accounts")
// public class User {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private Long id;
// 
//     @Column(name = "email", length = 100, nullable = false, unique = true)
//     private String email;
// 
//     @Column(name = "user_name", length = 100, nullable = false,unique = true)
//     private String userName;
// 
//     @Column(name = "password", length = 255)
//     private String password;
// 
//     @Enumerated(EnumType.STRING)
//     @Column(name = "role", length = 20, nullable = false)
//     private Role role;
// 
//     @Enumerated(EnumType.STRING)
//     @Column(name = "sign_in_provider", length = 20)
//     private SocialMediaService signInProvider;
// 
//     @Column(name = "create_date")
//     private Date createDate = new Date();
// 
//     public Date getCreateDate() {
//         return createDate;
//     }
// 
//     public void setCreateDate(Date createDate) {
//         this.createDate = createDate;
//     }
// 
//     public User() {
// 
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getUserName() {
//         return userName;
//     }
// 
//     public void setUserName(String userName) {
//         this.userName = userName;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public Role getRole() {
//         return role;
//     }
// 
//     public void setRole(Role role) {
//         this.role = role;
//     }
// 
//     public SocialMediaService getSignInProvider() {
//         return signInProvider;
//     }
// 
//     public void setSignInProvider(SocialMediaService signInProvider) {
//         this.signInProvider = signInProvider;
//     }
// }


import io.loli.box.entity.User;
import javax.transaction.Transactional;
import java.io.IOException;
import java.io.InputStream;
package io.loli.box.service;



/**
 * All storage service should implements this interface
 *
 * @author choco
 */
public interface StorageService {

    /**
     * Upload an InputStream with file name
     *
     * @param is          file to upload. After uploaded, file name will be changed to
     *                    nano time.
     * @param filename    origin name of this file
     * @param contentType
     * @return A relative url str generated by storage service
     * @throws IOException Will be throwed while IO error occurred
     */
    public String upload(InputStream is, String filename, String contentType, long length) throws IOException;


    @Transactional
    public void deleteFile(String name);

    @Transactional
// Path: lolibox-server/src/main/java/io/loli/box/entity/User.java
// @Entity
// @Table(name = "user_accounts")
// public class User {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.AUTO)
//     private Long id;
// 
//     @Column(name = "email", length = 100, nullable = false, unique = true)
//     private String email;
// 
//     @Column(name = "user_name", length = 100, nullable = false,unique = true)
//     private String userName;
// 
//     @Column(name = "password", length = 255)
//     private String password;
// 
//     @Enumerated(EnumType.STRING)
//     @Column(name = "role", length = 20, nullable = false)
//     private Role role;
// 
//     @Enumerated(EnumType.STRING)
//     @Column(name = "sign_in_provider", length = 20)
//     private SocialMediaService signInProvider;
// 
//     @Column(name = "create_date")
//     private Date createDate = new Date();
// 
//     public Date getCreateDate() {
//         return createDate;
//     }
// 
//     public void setCreateDate(Date createDate) {
//         this.createDate = createDate;
//     }
// 
//     public User() {
// 
//     }
// 
//     public String getEmail() {
//         return email;
//     }
// 
//     public void setEmail(String email) {
//         this.email = email;
//     }
// 
//     public String getUserName() {
//         return userName;
//     }
// 
//     public void setUserName(String userName) {
//         this.userName = userName;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public void setId(Long id) {
//         this.id = id;
//     }
// 
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public Role getRole() {
//         return role;
//     }
// 
//     public void setRole(Role role) {
//         this.role = role;
//     }
// 
//     public SocialMediaService getSignInProvider() {
//         return signInProvider;
//     }
// 
//     public void setSignInProvider(SocialMediaService signInProvider) {
//         this.signInProvider = signInProvider;
//     }
// }


// Path: lolibox-server/src/main/java/io/loli/box/service/StorageService.java
import io.loli.box.entity.User;
import javax.transaction.Transactional;
import java.io.IOException;
import java.io.InputStream;

package io.loli.box.service;



/**
 * All storage service should implements this interface
 *
 * @author choco
 */
public interface StorageService {

    /**
     * Upload an InputStream with file name
     *
     * @param is          file to upload. After uploaded, file name will be changed to
     *                    nano time.
     * @param filename    origin name of this file
     * @param contentType
     * @return A relative url str generated by storage service
     * @throws IOException Will be throwed while IO error occurred
     */
    public String upload(InputStream is, String filename, String contentType, long length) throws IOException;


    @Transactional
    public void deleteFile(String name);

    @Transactional
    boolean deleteFile(String name, User user);