WriteBodyLength 写入Body长度数据
(bodyLength int64)
| 109 | |
| 110 | // WriteBodyLength 写入Body长度数据 |
| 111 | func (this *FileWriter) WriteBodyLength(bodyLength int64) error { |
| 112 | if this.metaBodySize >= 0 && bodyLength == this.metaBodySize { |
| 113 | return nil |
| 114 | } |
| 115 | var bytes8 = make([]byte, 8) |
| 116 | binary.BigEndian.PutUint64(bytes8, uint64(bodyLength)) |
| 117 | _, err := this.rawWriter.Seek(SizeExpiresAt+SizeStatus+SizeURLLength+SizeHeaderLength, io.SeekStart) |
| 118 | if err != nil { |
| 119 | _ = this.Discard() |
| 120 | return err |
| 121 | } |
| 122 | _, err = this.rawWriter.Write(bytes8) |
| 123 | if err != nil { |
| 124 | _ = this.Discard() |
| 125 | return err |
| 126 | } |
| 127 | return nil |
| 128 | } |
| 129 | |
| 130 | // Close 关闭 |
| 131 | func (this *FileWriter) Close() error { |