Skip to content

Commit 476a649

Browse files
finish overhauling upload code
1 parent c5c8e84 commit 476a649

File tree

3 files changed

+185
-264
lines changed

3 files changed

+185
-264
lines changed

apps/desktop/src-tauri/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ async fn upload_exported_video(
11161116
}
11171117
.await?;
11181118

1119-
let upload_id = s3_config.id().to_string();
1119+
let upload_id = s3_config.id.to_string();
11201120

11211121
match upload_video(
11221122
&app,
@@ -1125,7 +1125,7 @@ async fn upload_exported_video(
11251125
meta.project_path.join("screenshots/display.jpg"),
11261126
s3_config,
11271127
metadata,
1128-
Some(channel.clone()),
1128+
// Some(channel.clone()),
11291129
)
11301130
.await
11311131
{

apps/desktop/src-tauri/src/recording.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use cap_recording::{
1313
};
1414
use cap_rendering::ProjectRecordingsMeta;
1515
use cap_utils::{ensure_dir, spawn_actor};
16+
use futures::stream;
1617
use serde::Deserialize;
1718
use specta::Type;
1819
use std::{path::PathBuf, str::FromStr, sync::Arc, time::Duration};
@@ -24,16 +25,15 @@ use tracing::{debug, error, info};
2425
use crate::{
2526
App, CurrentRecordingChanged, MutableState, NewStudioRecordingAdded, RecordingState,
2627
RecordingStopped, VideoUploadInfo,
27-
api::{PresignedS3PutRequest, PresignedS3PutRequestMethod},
28+
api::PresignedS3PutRequestMethod,
2829
audio::AppSounds,
2930
auth::AuthStore,
3031
create_screenshot,
3132
general_settings::{GeneralSettingsStore, PostDeletionBehaviour, PostStudioRecordingBehaviour},
3233
open_external_link,
3334
presets::PresetsStore,
3435
upload::{
35-
InstantMultipartUpload, build_video_meta, bytes_into_stream, compress_image,
36-
create_or_get_video, do_presigned_upload, upload_video,
36+
InstantMultipartUpload, build_video_meta, compress_image, create_or_get_video, upload_video,
3737
},
3838
web_api::ManagerExt,
3939
windows::{CapWindowId, ShowCapWindow},
@@ -263,11 +263,11 @@ pub async fn start_recording(
263263
)
264264
.await
265265
{
266-
let link = app.make_app_url(format!("/s/{}", s3_config.id())).await;
266+
let link = app.make_app_url(format!("/s/{}", s3_config.id)).await;
267267
info!("Pre-created shareable link: {}", link);
268268

269269
Some(VideoUploadInfo {
270-
id: s3_config.id().to_string(),
270+
id: s3_config.id.to_string(),
271271
link: link.clone(),
272272
config: s3_config,
273273
})
@@ -807,23 +807,22 @@ async fn handle_recording_finish(
807807
let _ = screenshot_task.await;
808808

809809
if video_upload_succeeded {
810-
if let Ok(result) =
810+
if let Ok(bytes) =
811811
compress_image(display_screenshot).await
812812
.map_err(|err|
813813
error!("Error compressing thumbnail for instant mode progressive upload: {err}")
814814
) {
815-
let (stream, total_size) = bytes_into_stream(result);
816-
do_presigned_upload(
817-
&app,
818-
stream,
819-
total_size,
815+
crate::upload::singlepart_uploader(
816+
app.clone(),
820817
crate::api::PresignedS3PutRequest {
821818
video_id: video_upload_info.id.clone(),
822819
subpath: "screenshot/screen-capture.jpg".to_string(),
823820
method: PresignedS3PutRequestMethod::Put,
824821
meta: None,
825822
},
826-
|p| {} // TODO: Progress reporting
823+
bytes.len() as u64,
824+
stream::once(async move { Ok::<_, std::io::Error>(bytes::Bytes::from(bytes)) }),
825+
827826
)
828827
.await
829828
.map_err(|err| {
@@ -843,7 +842,6 @@ async fn handle_recording_finish(
843842
display_screenshot.clone(),
844843
video_upload_info.config.clone(),
845844
meta,
846-
None,
847845
)
848846
.await
849847
{

0 commit comments

Comments
 (0)