I have been trying to upload and download files to and from google cloud .
public static class Program
{
public static void Main(string[] args)
{
string bucketName = "uploads";
// Explicitly use service account credentials by specifying the private key file.
GoogleCredential credential = null;
using (var jsonStream = new FileStream("credentials.json", FileMode.Open,
FileAccess.Read, FileShare.Read))
{
credential = GoogleCredential.FromStream(jsonStream);
}
var storageClient = StorageClient.Create(credential);
//using (var fileStream = new FileStream("C:\\...", FileMode.Open,
// FileAccess.Read, FileShare.Read))
//{
// storageClient.UploadObject(bucketName, "file1", "text/plain", fileStream);
//}
//List objects
foreach (var obj in storageClient.ListObjects(bucketName, ""))
{
Console.WriteLine(obj.Name);
}
// Download file
using (var fileStream = File.Create("C:\\...))
{
storageClient.DownloadObject(bucketName, "myfile.csv", fileStream);
It works fine with uploading and showing what files i have in the cloud bucket. But i am getting this error for downloading files.Unhandled Exception: Google.GoogleApiException: The service storage has thrown an exception. HttpStatusCode is NotFound. No error message was specified. ---> Newtonsoft.Json.JsonReaderException: Error parsing NaN value. Path '', line 1, position 1. ERROR
Any possible solution ?
I tried looking up if that happened to anyone but couldn't find anything.
Path '', line 1, position 1in the error generally means ‘this isn’t Json’ but yes, why it should try and parse a 404 is.. odd.DeserializeErrorAsyncsuggests might be the case