View Javadoc
1   /*
2    * Copyright (c) 2002-2021, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.blobstore.service;
35  
36  import java.io.InputStream;
37  import java.io.Serializable;
38  import org.apache.commons.fileupload.FileItem;
39  
40  /**
41   * Blob Store Service Interface. <i>*InputStream</i> methods should be used for very large blobs.
42   */
43  public interface IBlobStoreService extends Serializable
44  {
45      /**
46       * Store a blob
47       * 
48       * @param blob
49       *            The blob
50       * @return The key of the blob
51       */
52      String store( byte [ ] blob );
53  
54      /**
55       * Stores an input stream
56       * 
57       * @param inputStream
58       *            the input stream
59       * @return The key of the blob
60       */
61      String storeInputStream( InputStream inputStream );
62  
63      /**
64       * Get a blob
65       * 
66       * @param strKey
67       *            The key of the blob
68       * @return The blob
69       */
70      byte [ ] getBlob( String strKey );
71  
72      /**
73       * Gets a blob as {@link InputStream}
74       * 
75       * @param strKey
76       *            the key
77       * @return the {@link InputStream}
78       */
79      InputStream getBlobInputStream( String strKey );
80  
81      /**
82       * Stores a FileItem
83       *
84       * @param fileItem
85       * @return The key of the blob
86       */
87      String storeFileItem( FileItem fileItem );
88  
89      /**
90       * Update a blob
91       * 
92       * @param strKey
93       *            The key of the blob
94       * @param blob
95       *            The new blob
96       */
97      void update( String strKey, byte [ ] blob );
98  
99      /**
100      * Updates a blob key with the inputstream
101      * 
102      * @param strKey
103      *            the blob key
104      * @param inputStream
105      *            the input stream
106      */
107     void updateInputStream( String strKey, InputStream inputStream );
108 
109     /**
110      * Delete a blob
111      * 
112      * @param strKey
113      *            The key of the blob
114      */
115     void delete( String strKey );
116 
117     /**
118      * Gets the blob URL.
119      *
120      * @param strKey
121      *            the str key
122      * @return the blob url
123      */
124     String getBlobUrl( String strKey );
125 
126     /**
127      * Gets the file download url (for {@link BlobStoreFileItem})
128      * 
129      * @param strKey
130      *            the
131      * @return the download link
132      */
133     String getFileUrl( String strKey );
134 
135     /**
136      * Gets the blobstore name
137      * 
138      * @return the blobstore name
139      */
140     String getName( );
141 
142     /**
143      * Sets the blobstore name
144      * 
145      * @param strName
146      *            the name
147      */
148     void setName( String strName );
149 }