
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
- [Node.js SDK] Bypass 2GB file limit?
Hello. Using either InputFile.fromPath or InputFile.fromBuffer throws this error: File size (2295467305) is greater than 2 GiB Bucket limit etc. is setup corre...
- Hi im using vvs studio to make a charact...
my game involves magic , leveling up aka "phase" max phase is 30 each 10 20 30 theres awakening 1 2 3 i want to make a character builder so that players can fig...
- Limit File Upload count?
Is there a way to limit the number of files a user can upload? I know there's a limit of file size but in my case I'd like to limit the user to only upload x am...
