Language: C++
Platform: Windows
Hello.
I am trying to realize the downloading of a future updates of my C++ plugin.
I want to achieve in result the posibility to download the new file or folder from my web adress and replace the old one.
For it I am using this code snipped: https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_maxonapi_files_inputstream.html#page_maxonapi_files_inputstream_use
("// This example loads a file from the web and saves it to the local file system.")
But I receive an error on this line:
const maxon::InputStreamRef inputStream = webFile.OpenInputStream() iferr_return;
- Error (active) E0312 no suitable user-defined conversion from "maxon::MacroArgType<void (maxon::Resultmaxon::InputStreamRef)>" to "const maxon::InputStreamRef" exists*
What am I doing wrong?
On SDK help search there is no a link to a "InputStreamRef".
The code:
const maxon::Url webFile = (maxon::Url("https://www.mysite.com/Somevideo.mp4"_s))iferr_return; // just for tests
// check if the given URL references a file on the web
const maxon::UrlScheme scheme = webFile.GetScheme();
const maxon::Bool isHTTP = scheme == maxon::URLSCHEME_HTTP;
const maxon::Bool isHTTPS = scheme == maxon::URLSCHEME_HTTPS;
if (isHTTP || isHTTPS)
{
// read data
// input stream
webFile.OpenInputStream();
const maxon::InputStreamRef inputStream = webFile.OpenInputStream() iferr_return;
const maxon::Int length = inputStream.GetStreamLength() iferr_return;
maxon::BaseArray<maxon::Char> data;
data.Resize(length) iferr_return;
inputStream.Read(data) iferr_return;
inputStream.Close() iferr_return;
// save data to file
// prepare file name
const maxon::Url localFile = (sad)iferr_return;
const maxon::Url localFile = (targetFolder + webFile.GetName())iferr_return;
// output stream
const maxon::OutputStreamRef outputStream = localFile.OpenOutputStream() iferr_return;
// write to file
outputStream.Write(data) iferr_return;
outputStream.Close() iferr_return;
}