Reputation: 126
I am struggling with modifying the data in stream which i got from google cloud bucket. Here is the code to get the stream -
var storageService = new StorageService(new BaseClientService.Initializer()
{
HttpClientInitializer = googleCredential,
});
var getRequest = storageService.Objects.Get(bucketName, fileName);
var stream = await getRequest.ExecuteAsStreamAsync();
Then i am using openxml sdk to modify this stream with some token replacement and then download a new document in browser.
public static void ReplaceTokens(Stream stream, DocumentTemplateTokenData data)
{
try
{
using (var doc = WordprocessingDocument.Open(stream, true))
{
// token replacement in doc
}
}
catch(exception ex)
{}
this is giving me error that stream was not opened to writing. PLease help, already wasted lot of time trying many solutions.
Upvotes: 1
Views: 95