Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HIMSScannerService
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HIMSScanner
HIMSScannerService
Commits
b51b6e56
Commit
b51b6e56
authored
Dec 06, 2024
by
Kundena Mohan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Upload method with large files
Signed-off-by:
kmohan
<
kmohan@sujainfo.net
>
parent
5390b81f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
FTPManagementAPIController.cs
Controllers/FTPManagementAPIController.cs
+0
-0
Base64EncodingStream .cs
Models/Base64EncodingStream .cs
+77
-0
No files found.
Controllers/FTPManagementAPIController.cs
View file @
b51b6e56
This diff is collapsed.
Click to expand it.
Models/Base64EncodingStream .cs
0 → 100644
View file @
b51b6e56
using
System.Text
;
public
class
Base64EncodingStream
:
Stream
{
private
readonly
Stream
_innerStream
;
private
readonly
MemoryStream
_base64BufferStream
=
new
MemoryStream
();
private
bool
_endOfStream
=
false
;
public
Base64EncodingStream
(
Stream
innerStream
)
{
_innerStream
=
innerStream
??
throw
new
ArgumentNullException
(
nameof
(
innerStream
));
}
public
override
bool
CanRead
=>
true
;
public
override
bool
CanSeek
=>
false
;
public
override
bool
CanWrite
=>
false
;
public
override
long
Length
=>
throw
new
NotSupportedException
();
public
override
long
Position
{
get
=>
throw
new
NotSupportedException
();
set
=>
throw
new
NotSupportedException
();
}
public
override
void
Flush
()
=>
throw
new
NotSupportedException
();
public
override
int
Read
(
byte
[]
buffer
,
int
offset
,
int
count
)
{
if
(
_endOfStream
&&
_base64BufferStream
.
Length
==
0
)
return
0
;
// End of stream
// Fill the Base64 buffer if it's empty
if
(
_base64BufferStream
.
Length
==
0
)
{
byte
[]
readBuffer
=
new
byte
[
81920
];
// 80 KB
int
bytesRead
=
_innerStream
.
Read
(
readBuffer
,
0
,
readBuffer
.
Length
);
if
(
bytesRead
>
0
)
{
string
base64Chunk
=
Convert
.
ToBase64String
(
readBuffer
,
0
,
bytesRead
);
byte
[]
base64Bytes
=
Encoding
.
UTF8
.
GetBytes
(
base64Chunk
);
_base64BufferStream
.
Write
(
base64Bytes
,
0
,
base64Bytes
.
Length
);
_base64BufferStream
.
Position
=
0
;
// Reset position for reading
}
else
{
_endOfStream
=
true
;
}
}
// Read Base64 data from the buffer
int
bytesToCopy
=
Math
.
Min
(
count
,
(
int
)(
_base64BufferStream
.
Length
-
_base64BufferStream
.
Position
));
int
bytesCopied
=
_base64BufferStream
.
Read
(
buffer
,
offset
,
bytesToCopy
);
// If the Base64 buffer is exhausted, reset it
if
(
_base64BufferStream
.
Position
==
_base64BufferStream
.
Length
)
{
_base64BufferStream
.
SetLength
(
0
);
_base64BufferStream
.
Position
=
0
;
}
return
bytesCopied
;
}
public
override
long
Seek
(
long
offset
,
SeekOrigin
origin
)
=>
throw
new
NotSupportedException
();
public
override
void
SetLength
(
long
value
)
=>
throw
new
NotSupportedException
();
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
count
)
=>
throw
new
NotSupportedException
();
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
)
{
_innerStream
?.
Dispose
();
_base64BufferStream
?.
Dispose
();
}
base
.
Dispose
(
disposing
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment