@@ -38,7 +38,16 @@ type Writer struct {
3838
3939// NewWriter returns a new Writer writing an OPC file to w.
4040func NewWriter (w io.Writer ) * Writer {
41- return & Writer {p : newPackage (), w : zip .NewWriter (w ), rnd : rand .New (rand .NewSource (42 ))}
41+ return & Writer {p : & pkg {
42+ parts : make (map [string ]* Part , 0 ),
43+ contentTypes : contentTypes {
44+ defaults : map [string ]string {
45+ "xml" : "application/xml" ,
46+ "rels" : relationshipContentType ,
47+ },
48+ overrides : map [string ]string {},
49+ },
50+ }, w : zip .NewWriter (w ), rnd : rand .New (rand .NewSource (42 ))}
4251}
4352
4453// Flush flushes any buffered data to the underlying writer.
@@ -78,8 +87,7 @@ func (w *Writer) Close() error {
7887// This returns a Writer to which the file contents should be written.
7988// The file's contents must be written to the io.Writer before the next call to Create, CreatePart, or Close.
8089func (w * Writer ) Create (name , contentType string ) (io.Writer , error ) {
81- part := & Part {Name : name , ContentType : contentType }
82- return w .add (part , CompressionNormal )
90+ return w .CreatePart (& Part {Name : name , ContentType : contentType }, CompressionNone )
8391}
8492
8593// CreatePart adds a file to the OPC archive using the provided part.
@@ -113,7 +121,7 @@ func (w *Writer) createCoreProperties() error {
113121
114122func (w * Writer ) createContentTypes () error {
115123 // ISO/IEC 29500-2 M3.10
116- cw , err := w .addToPackage (& Part {Name : contentTypesName , ContentType : "text /xml" }, CompressionNormal )
124+ cw , err := w .addToPackage (& Part {Name : contentTypesName , ContentType : "application /xml" }, CompressionNormal )
117125 if err != nil {
118126 return err
119127 }
0 commit comments