File tree Expand file tree Collapse file tree
livekit-uniffi/src/data_stream Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- use std:: path:: PathBuf ;
1615use std:: sync:: Arc ;
1716
1817use bytes:: { Bytes , BytesMut } ;
@@ -112,28 +111,6 @@ impl ByteStreamReader {
112111 }
113112 Ok ( buffer. freeze ( ) )
114113 }
115-
116- /// Streams the contents to a file as chunks arrive, returning the written path.
117- ///
118- /// `directory` defaults to the system temp dir; `name_override` defaults to the stream name.
119- pub async fn write_to_file (
120- & self ,
121- directory : Option < String > ,
122- name_override : Option < String > ,
123- ) -> Result < String , DataStreamError > {
124- use tokio:: io:: AsyncWriteExt as _;
125- let directory = directory. map ( PathBuf :: from) . unwrap_or_else ( std:: env:: temp_dir) ;
126- let name = name_override. unwrap_or_else ( || self . info . name . clone ( ) ) ;
127- let path = directory. join ( name) ;
128-
129- let mut reader = self . inner . lock ( ) . await ;
130- let mut file = tokio:: fs:: File :: create ( & path) . await . map_err ( ds_api:: StreamError :: Io ) ?;
131- while let Some ( chunk) = reader. next ( ) . await {
132- file. write_all ( & chunk?) . await . map_err ( ds_api:: StreamError :: Io ) ?;
133- }
134- file. flush ( ) . await . map_err ( ds_api:: StreamError :: Io ) ?;
135- Ok ( path. to_string_lossy ( ) . into_owned ( ) )
136- }
137114}
138115
139116/// Reader for an incoming text data stream.
You can’t perform that action at this time.
0 commit comments