Rank 2: Process
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.
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 2: Process
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
Rank 2: Process
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);
}
}
}
}
Rank 2: Process
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'.'"
Rank 2: Process
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?
Rank 2: Process
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
Rank 2: Process
Thanks for the update. Does this bug is in the .net sdk or the rest api?
SDK
Rank 2: Process
Thanks
Rank 2: Process
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.
Rank 2: Process
//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")
Rank 2: Process
latest - 0.41
Rank 2: Process
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
Rank 2: Process
it not working event like that with the .path property. can you ask from the .net sdk developer to look on that ?
Rank 2: Process
resolved...thanks. ( Appwrite.Models.File uploadfile = await storage.CreateFile(bucketid,ID.Unique(), InputFile.FromPath("c:/test/nature.jpg"), perms, onProgress);
Appwrite, not the SDK
Rank 2: Process
I
t's working so thank you steven..
[SOLVED] .net sdk (beta) - createfile