Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
radek7210 opened this issue Aug 17, 2022 · 0 comments
Open

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

radek7210 opened this issue Aug 17, 2022 · 0 comments

Comments

@radek7210
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant