BraCa Posted November 7, 2023 Posted November 7, 2023 (edited) Hi, I'm using the REST API to upload files I use the following endpoints: "index.php?/downloads/files" and "index.php?/downloads/files/{fileId}/history" (depending if I'm uploading a new version for an existent file or not) Anyway, regardless of the endpoint, all the files that I uploaded through the API are stored with a version date of "Released January 1, 1970" When I upload them via the website, the version date is stored properly, this only happens when I use the REST API to upload files Thanks Edited November 7, 2023 by BraCa
Marc Posted November 7, 2023 Posted November 7, 2023 Please could you show the code you are using to upload those?
BraCa Posted November 8, 2023 Author Posted November 8, 2023 On 11/7/2023 at 2:13 PM, Marc Stridgen said: Please could you show the code you are using to upload those? Yes, but it's not PHP, it's written in C#, but here it goes var fileContentsAsByteArray = await File.ReadAllBytesAsync(filepath).ConfigureAwait(false); var fileContents = HttpUtility.UrlEncode(fileContentsAsByteArray); var body = new Dictionary<string, string> { { "category", request.CategoryId.ToString() }, { "author", request.AuthorId.ToString() }, { "title", HttpUtility.UrlEncode(request.Title)}, { "description", HttpUtility.UrlEncode(request.Description)}, { $"files[{request.Filename}]", fileContents}, }; if (!string.IsNullOrWhiteSpace(request.Version)) { body["version"] = HttpUtility.UrlEncode(request.Version); } if (!string.IsNullOrWhiteSpace(request.Changelog)) { body["changelog"] = HttpUtility.UrlEncode(request.Changelog); } var bodyString = body.ConvertToQueryString(); var uriPath = fileId.HasValue ? $"index.php?/downloads/files/{fileId.Value}/history" : "index.php?/downloads/files"; var response = await httpClient.PostAsync<UploadFileResult>( httpClient.BaseAddress, uriPath, bodyString, contentType: "application/x-www-form-urlencoded").ConfigureAwait(false);
Jim M Posted November 8, 2023 Posted November 8, 2023 If you supply a date or updated value passed appropriately, do you get the same response?
BraCa Posted November 9, 2023 Author Posted November 9, 2023 3 hours ago, Jim M said: If you supply a date or updated value passed appropriately, do you get the same response? I will try, but just to be clear, do you mean to add to the body new properties named "date" and "updated"? Also, in what format should those values be?
Marc Posted November 9, 2023 Posted November 9, 2023 Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release. BraCa 1
Solution Marc Posted January 24 Solution Posted January 24 This issue has been resolved in the recently released 4.7.15 version. Please update your site if you are still experiencing the issue, and let us know if you see any reoccurrence. BraCa 1
Recommended Posts