@@ -50,16 +50,26 @@ public class DocumentListEntry extends MediaEntry<DocumentListEntry> {
50
50
* Represents the MIME types supported by the doclist GData feed
51
51
*/
52
52
public enum MediaType {
53
- CSV ("text/comma-separated-values" ),
54
- DOC ("application/msword" ),
55
- ODS ("application/vnd.oasis.opendocument.spreadsheet" ),
53
+ JPG ("image/jpeg" ),
54
+ JPEG ("image/jpeg" ),
55
+ PNG ("image/png" ),
56
+ BMP ("image/bmp" ),
57
+ GIF ("image/gif" ),
58
+ TXT ("text/plain" ),
59
+ HTML ("text/html" ),
60
+ HTM ("text/html" ),
56
61
ODT ("application/vnd.oasis.opendocument.text" ),
62
+ SXW ("application/vnd.sun.xml.writer" ),
63
+ DOC ("application/msword" ),
64
+ RTF ("application/rtf" ),
57
65
PPS ("application/vnd.ms-powerpoint" ),
58
66
PPT ("application/vnd.ms-powerpoint" ),
59
- RTF ("application/rtf" ),
60
- SXW ("application/vnd.sun.xml.writer" ),
61
- TXT ("text/plain" ),
62
- XLS ("application/vnd.ms-excel" );
67
+ XLS ("application/vnd.ms-excel" ),
68
+ ODS ("application/x-vnd.oasis.opendocument.spreadsheet" ),
69
+ CSV ("text/csv" ),
70
+ TAB ("text/tab-separated-value" ),
71
+ TSV ("text/tab-separated-value" ),
72
+ ;
63
73
64
74
private String mimeType ;
65
75
@@ -81,6 +91,18 @@ public static MediaType fromFileName(String fileName) {
81
91
}
82
92
}
83
93
94
+ /**
95
+ * Returns the mime type given a file name. Not intended for extenal
96
+ * use, see setFile(File, String) instead. protected access for
97
+ * testing.
98
+ *
99
+ * @throws IllegalArgumentException if the mime type is not known
100
+ * given the file name
101
+ */
102
+ protected static String getMimeTypeFromFileName (String fileName ) {
103
+ return MediaType .fromFileName (fileName ).getMimeType ();
104
+ }
105
+
84
106
public static final String DOCUMENT_NAMESPACE
85
107
= "http://schemas.google.com/docs/2007" ;
86
108
@@ -157,13 +179,25 @@ public String getId() {
157
179
return result ;
158
180
}
159
181
182
+ /**
183
+ * Associate a File with this entry, implicitly determining the mime type
184
+ * from the file's extension.
185
+ *
186
+ * @deprecated Prefer setFile(File, String)
187
+ */
188
+ @ Deprecated
160
189
public void setFile (File file ) throws IOException {
161
- MediaType mediaType = MediaType .fromFileName (file .getName ());
162
- MediaFileSource fileSource = new MediaFileSource (file ,
163
- mediaType .getMimeType ());
190
+ setFile (file , getMimeTypeFromFileName (file .getName ()));
191
+ }
192
+
193
+ /**
194
+ * Associate a File with this entry with the specified mime type
195
+ */
196
+ public void setFile (File file , String mimeType ) throws IOException {
197
+ MediaFileSource fileSource = new MediaFileSource (file , mimeType );
164
198
MediaContent content = new MediaContent ();
165
199
content .setMediaSource (fileSource );
166
- content .setMimeType (new ContentType (mediaType . getMimeType () ));
200
+ content .setMimeType (new ContentType (mimeType ));
167
201
setContent (content );
168
202
}
169
203
0 commit comments