
my problem is related to permitition - i get exception "e.Message = "Invalid permissions: Invalid permission string format: write.".. i tryed serval options like "any", "write", "files.write" in all of the i get exception.

What is your code?
The examples wouldn't show permissions anyways.
And the permissions should be the same creating a document

using Appwrite; using Appwrite.Services; using Appwrite.Models; using System; using System.IO; using System.Net.Http; using System.Threading.Tasks; using System.Collections.Generic;
namespace playground_for_dotnet { class Program { static async Task Main(string[] args) { Client client = new Client();
client.SetEndpoint("https://cloud.appwrite.io/v1");
client.SetProject("");
client.SetKey("");
client.SetSelfSigned(true);
//Storage
Storage storage = new Storage(client);
//BucketID
string bucketid = "645b1e668687ffe89f12";
//InputFile
InputFile inputfile = new InputFile();
inputfile.Path = @"c:\test\";
inputfile.Filename = "nature.jpg";
//Permitions
List<string> perms = new List<string>() { Permission.Write(Role.Any()) };
Action<UploadProgress> onProgress = null;
try
{
Appwrite.Models.File uploadfile = await storage.CreateFile(bucketid, ID.Unique(), inputfile, perms, onProgress);
}
catch (AppwriteException e)
{
Console.WriteLine(e.Message);
}
}
}
}

Hi Steven, i resolved the permitions issue but i get exception 'System.InvalidCastException: 'Unable to cast object of type 'System.DateTime' to type 'System.String'.'"

i can not find what is the reason for that..

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

Do you have a full stack trace?

Hi i didnt manage to capture the fulk stack exception yet. i'm using the appwrite cloud. does the sdk beta if compatiable with the cloud version ?

Maybe you can manually print the stack trace? How do you do that in dotnet?

Actually, the fix for this should be coming soon

Thanks for the update. Does this bug is in the .net sdk or the rest api?

SDK

Thanks

Hi, the crash is resolved with the new SDK version but when the file is upload it shown as size 0 and mime type: application/x-empty.

//InputFile InputFile inputfile = new InputFile(); inputfile.Path = @"c:\test; inputfile.Filename = "nature.jpg"; inputfile.MimeType = "image/jpeg";
//Permitions
List<string> perms = new List<string>() { Permission.Write(Role.Any()) };
Action<UploadProgress> onProgress = null;
try
{
Appwrite.Models.File uploadfile = await storage.CreateFile(bucketid,ID.Unique(), inputfile, perms, onProgress);
}
catch (AppwriteException e)
{
Console.WriteLine(e.Message);
//Console.WriteLine(e.StackTrace);
}

what version of Appwrite?

don't forget to format code using backticks

also, we typically use the static methods for instantiating InputFile like InputFile.FromPath("[DIRECTORY_PATH]/nature.png")

latest - 0.41

with the .net SDK there is no ".Fromfile is has only properties of .path and .file. if the .file is null than exception is raised. the website docs doesn't have examples for c# yet so i'm trying that it will work

it not working event like that with the .path property. can you ask from the .net sdk developer to look on that ?

resolved...thanks. ( Appwrite.Models.File uploadfile = await storage.CreateFile(bucketid,ID.Unique(), InputFile.FromPath("c:/test/nature.jpg"), perms, onProgress);

Appwrite, not the SDK

I<:github:1112062009194848336> t's working so thank you steven..

[SOLVED] .net sdk (beta) - createfile
Recommended threads
- Web SDK chunk upload to Storage without ...
As discussed in this older thread (https://discord.com/channels/564160730845151244/1216821517749321808), the Read permission for Any needs to be enabled in orde...
- Storage getFilePreview for GIF file retu...
Used to work in 1.6.x but with 1.7.4 upgrade it seems to be broken.
- CORS errors with storage bucket
I have a javascript file in the storage bucket and I used the view endpoint in an `src` attribute of a `<script>` tag. But I am getting the `net::ERR_BLOCKED_BY...
