appwrite/sdk-generator

๐Ÿ› Bug Report: Error in Storage API createFile function

abhishek-visitnow opened this issue ยท 7 comments

๐Ÿ‘Ÿ Reproduction steps

I'm trying to upload a file greater than 4 Mb. Following code is working when the size of file is less than 4 mb.

Using dotnet sdk v0.8.3

File myfile = await storage.CreateFile(
                 bucketId: "bucket-id",
                 fileId: ID.Unique(),
                 file: InputFile.FromBytes(
                     Encoding.UTF8.GetBytes(json),
                     "filename.json,
                     "application/json"
                     ),
                 permissions: permissions! // optional
             );

๐Ÿ‘ Expected behavior

It should upload the file.

๐Ÿ‘Ž Actual Behavior

Getting following error:

Appwrite.AppwriteException: The requested route was not found. Please refer to the API docs and try again.
   at Appwrite.Client.Call[T](String method, String path, Dictionary`2 headers, Dictionary`2 parameters, Func`2 convert)
   at Appwrite.Client.ChunkedUpload[T](String path, Dictionary`2 headers, Dictionary`2 parameters, Func`2 converter, String paramName, String idParamName, Action`1 onProgress)
   at DotNetRuntime.Handler.Main(RuntimeContext Context) in /usr/local/server/src/Index.cs:line 67
   at DotNetRuntime.Program.Action(HttpRequest request) in /usr/local/server/src/Program.cs:line 194

๐ŸŽฒ Appwrite version

Version 1.5.x

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

@adityaoberai looked into this and noticed we're still checking for "unique()"

https://github.com/appwrite/sdk-for-dotnet/blob/e0ca49126bb8cf97b0826c8acd7af12b244ea920/Appwrite/Client.cs#L408

even though ID.unique() doesn't return "unique()" anymore:

https://github.com/appwrite/sdk-for-dotnet/blob/e0ca49126bb8cf97b0826c8acd7af12b244ea920/Appwrite/ID.cs#L22-L35

Looks like we're going to need to fix this in the following SDKs:

@stnguyen90 Does this mean it will work if I add a string Id to fileId?

I see the variable name is mismatched path: "$path/${params[idParamName]}",. Right one: path: "$path/${parameters[idParamName]}",

@stnguyen90 Any update on this?

Any plan for when this fix is going to be released?

New version of DotNet SDK is released
https://github.com/appwrite/sdk-for-dotnet/releases/tag/0.10.1

With a release note: fix: chunk upload by @byawitz in #52

I installed this version and ran a test. Now new error appears:

Unhandled exception. System.AggregateException: One or more errors occurred. (<Error><Code>EntityTooSmall</Code><Message>Your proposed upload is smaller than the minimum allowed size</Message><ProposedSize>5242879</ProposedSize><MinSizeAllowed>5242880</MinSizeAllowed><PartNumber>1</PartNumber><ETag>957c613714e7d16b7ded33a219d44296</ETag><RequestId>MYQY22S4WCGBKZNG</RequestId><HostId>aV7Q2T/3R8O7A9hkOJiLeMA+bc1y6gTBvIGv3OLJO09wdBy18uRnr6D7xvcuTcQJcrVJltzywh8=</HostId></Error>)
 ---> Appwrite.AppwriteException: <Error><Code>EntityTooSmall</Code><Message>Your proposed upload is smaller than the minimum allowed size</Message><ProposedSize>5242879</ProposedSize><MinSizeAllowed>5242880</MinSizeAllowed><PartNumber>1</PartNumber><ETag>957c613714e7d16b7ded33a219d44296</ETag><RequestId>MYQY22S4WCGBKZNG</RequestId><HostId>aV7Q2T/3R8O7A9hkOJiLeMA+bc1y6gTBvIGv3OLJO09wdBy18uRnr6D7xvcuTcQJcrVJltzywh8=</HostId></Error>
   at Appwrite.Client.Call[T](String method, String path, Dictionary`2 headers, Dictionary`2 parameters, Func`2 convert)
   at Appwrite.Client.ChunkedUpload[T](String path, Dictionary`2 headers, Dictionary`2 parameters, Func`2 converter, String paramName, String idParamName, Action`1 onProgress)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at DotNetRuntime.Program.Main(String[] args) in /src/Index.cs:line 43