Pan!cKk
Pan!cKk
CC#
Created by Pan!cKk on 7/16/2024 in #help
Multi-Instance Application with SignalR and Redis as backplane
UPDATE I believe the fix for this was configuring sticky-sessions on the ingress of the service in kubernetes, it seems to be working now
2 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
I will take a shot at this approach, thank you :)
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
I can download it chunk by chunk and do a multi part upload, within a ReadAsStream...?
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
What I want is to implement something that download a file part by part, and upload them to storage part by part... Download Part 1, Upload Part 1 Continue Downloading the second part, Upload Part 2 ... How many parts are decided base on the total fileSize / some chunkSize (in bytes)
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
it does not happen when try to read the whole file 🤷‍♂️
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
or could you send me some example? @Jimmacle
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
is there any article or stack overflow thread where I can rely?
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
It was something like this:
private async Task<byte[]> DownloadChunk(HttpResponseMessage response, long start, long end)
{
using(var memoryStream = new MemoryStream())
using(var responseStream = await response.Content.ReadAsStreamAsync())
{
var bufferSize = 10 * 1024 * 1024; // 10MB
var buffer = new byte[bufferSize];
int bytesRead;
int totalBytesRead = 0;

// Seek to the start position
responseStream.Seek(start, SeekOrigin.Begin);

while(totalBytesRead < end - start && (bytesRead = await responseStream.ReadAsync(buffer, 0, bufferSize)) > 0)
{
await memoryStream.WriteAsync(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}

return memoryStream.ToArray();
}
}
private async Task<byte[]> DownloadChunk(HttpResponseMessage response, long start, long end)
{
using(var memoryStream = new MemoryStream())
using(var responseStream = await response.Content.ReadAsStreamAsync())
{
var bufferSize = 10 * 1024 * 1024; // 10MB
var buffer = new byte[bufferSize];
int bytesRead;
int totalBytesRead = 0;

// Seek to the start position
responseStream.Seek(start, SeekOrigin.Begin);

while(totalBytesRead < end - start && (bytesRead = await responseStream.ReadAsync(buffer, 0, bufferSize)) > 0)
{
await memoryStream.WriteAsync(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}

return memoryStream.ToArray();
}
}
I am trying different methods, so the current state of my code has changed...
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
I tried using Streams, but I get such an error: The response ended prematurely, with at least 9823402 additional bytes expected.
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
FIle is to be downloaded from a given URL
20 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
thank you for your help <3
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
fair
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
How may I conclude if it does or not?
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
Yes, now I am. I tried your suggestion, but it doesn't seem to do the work (at least not what I am looking for...)
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
@333fred sorry for the ping, but I would appreciate your opinion!
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
I'm not sure if that is a huge issue for not so huge application ?
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
according to chatGPT, using StringEnumConverter, the cons are:
Cons:

Increased Payload Size: String representations generally occupy more space in JSON payloads compared to integer representations, potentially increasing network bandwidth usage and storage requirements.

Performance Overhead: Converting between enum values and strings requires additional processing compared to direct integer serialization/deserialization, which may have a slight impact on performance, especially in high-throughput scenarios.

Parsing Complexity: If using custom string representations, it might introduce parsing complexities, especially when dealing with edge cases or legacy data.

Compatibility with Existing Clients: If the consumers of your JSON data are expecting integer representations of enum values, switching to string representations might require updates on their end.

Loss of Type Safety: Using string representations loses some type safety compared to using integer values, as there's no compile-time check to ensure that the provided string corresponds to a valid enum value.
Cons:

Increased Payload Size: String representations generally occupy more space in JSON payloads compared to integer representations, potentially increasing network bandwidth usage and storage requirements.

Performance Overhead: Converting between enum values and strings requires additional processing compared to direct integer serialization/deserialization, which may have a slight impact on performance, especially in high-throughput scenarios.

Parsing Complexity: If using custom string representations, it might introduce parsing complexities, especially when dealing with edge cases or legacy data.

Compatibility with Existing Clients: If the consumers of your JSON data are expecting integer representations of enum values, switching to string representations might require updates on their end.

Loss of Type Safety: Using string representations loses some type safety compared to using integer values, as there's no compile-time check to ensure that the provided string corresponds to a valid enum value.
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
That did not really do the work for me. But I figured out I can use StringEnumConverter (Netwonsoft.Json) and it handles it well. I can pass either the integer value or the string representation, and it knows how to parse it (on post request), and the response has the respective string representation. May I ask if that is a good approach?
builder.Services.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});

public enum SourceType
{
[Description("Source Link")]
[EnumMember(Value = "Source Link")]
SourceLink = 1,
[Description("Channel")]
[EnumMember(Value = "Channel")]
Channel = 2,
[Description("Video")]
[EnumMember(Value = "Video")]
Video = 3
}
builder.Services.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});

public enum SourceType
{
[Description("Source Link")]
[EnumMember(Value = "Source Link")]
SourceLink = 1,
[Description("Channel")]
[EnumMember(Value = "Channel")]
Channel = 2,
[Description("Video")]
[EnumMember(Value = "Video")]
Video = 3
}
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
Trying to learn
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
I am not really familiar with the details :/
31 replies