Skip to content

CreateAssetAsync() - how to upload video from a local file #5

@radek7210

Description

@radek7210

Hello,

I am trying to create a new video asset from a local video file. The CreateAssetAsync() method's CreatesAssetRequest has the Url field, but I am not able to figure out how to upload a local file.

Example code:

using mux = Mux.Csharp.Sdk.Client;

mux.Configuration config = new();
config.BasePath = "https://api.mux.com";
config.Username = "9074...";
config.Password = "XtR....";

var api = new AssetsApi(config);
var request = new CreateAssetRequest
{
	Test = true,
	PlaybackPolicy = new List<PlaybackPolicy> { PlaybackPolicy.Signed },
	Input = new List<InputSettings> { new InputSettings {
	Type = InputSettings.TypeEnum.Video, 

	//Url = @"c:\Users\Radek\Desktop\test AT media\sample-mp4-file-small.mp4"
	//Url = "file:///c:/Users/Radek/Desktop/test AT media/sample-mp4-file-small.mp4"

	----> how should I specify a local file here????
	} }
};

AssetResponse response = await api.CreateAssetAsync(request);
return response ?? throw new Exception("MUX API CreateAssetAsync did not return any data");

I can see that the Post<T> method in ApiClient.cs supports posting files via the RequestOptions parameter, however the CreateAssetAsync() method does not contain any code to pass the filestream to the RequestOptions.Data property.

Can you suggest what am I doing wrong?

Thanks.

R.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions