Skip to main content
Language

To a Remote URL

VideoEditor SDK supports saving videos to a remote URL.

Open the editor and upload the video#

Open the video editor and handle the export result. After retrieving the exported video, save the VideoditorResult.video to your destination url. In this example, the upload will fail, since no valid remote URL is specified.

import 'package:catalog/models/code_example.dart';
import 'package:http/http.dart';
import 'package:video_editor_sdk/video_editor_sdk.dart';
class SaveVideoRemoteExample extends CodeExample {
void invoke() async {
try {
// Add a video from the assets directory.
final video = Video("assets/Skater.mp4");
// Open the video editor and handle the export as well as any occurring errors.
final result = await VESDK.openEditor(video);
if (result != null) {
// The user exported a new video successfully and the newly generated video is located at `result.video`.
// For this example, the video is uploaded to a remote URL.
final request =
MultipartRequest('POST', Uri.parse("YOUR-VALID-DESTINATION-URL"));
request.files.add(
await MultipartFile.fromPath('file', Uri.parse(result.video).path));
final response = await request.send();
if (response.statusCode != 200) {
throw "There was an error uploading the video.";
}
} else {
// The user tapped on the cancel button within the editor.
return;
}
} catch (error) {
// There was an error generating the video.
print(error);
}
}
}