Skip to content

Commit e610c96

Browse files
Merge pull request #547 from Funkrusha/feature/enable-post-requests
Add PostData to LoadURLOptions to allow http-posts in LoadURL calls
2 parents f3bd3d0 + 3838fe8 commit e610c96

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

ElectronNET.API/Entities/Blob.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public class Blob : IPostData
7+
{
8+
/// <summary>
9+
/// The object represents a Blob
10+
/// </summary>
11+
public string Type { get; } = "blob";
12+
13+
/// <summary>
14+
/// The UUID of the Blob being uploaded
15+
/// </summary>
16+
public string BlobUUID { get; set; }
17+
}
18+
}

ElectronNET.API/Entities/IPostData.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
/// Interface to use Electrons PostData Object
5+
/// </summary>
6+
public interface IPostData
7+
{
8+
/// <summary>
9+
/// One of the following:
10+
/// rawData - <see cref="UploadRawData"/> The data is available as a Buffer, in the rawData field.
11+
/// file - <see cref="UploadFile"/> The object represents a file. The filePath, offset, length and modificationTime fields will be used to describe the file.
12+
/// blob - <see cref="Blob"/> The object represents a Blob. The blobUUID field will be used to describe the Blob.
13+
/// </summary>
14+
public string Type { get; }
15+
}
16+
}

ElectronNET.API/Entities/LoadURLOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ public class LoadURLOptions
2626
/// Extra headers for the request.
2727
/// </summary>
2828
public string ExtraHeaders { get; set; }
29+
30+
/// <summary>
31+
/// PostData Object for the request.
32+
/// Can be <see cref="UploadRawData"/>, <see cref="UploadFile"/> or <see cref="Blob"/>
33+
/// </summary>
34+
public IPostData[] PostData { get; set; }
2935
}
3036
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public class UploadFile : IPostData
7+
{
8+
/// <summary>
9+
/// The object represents a file.
10+
/// </summary>
11+
public string Type { get; } = "file";
12+
13+
/// <summary>
14+
/// The path of the file being uploaded.
15+
/// </summary>
16+
public string FilePath { get; set; }
17+
18+
/// <summary>
19+
/// The offset from the beginning of the file being uploaded, in bytes. Defaults to 0.
20+
/// </summary>
21+
public long Offset { get; set; } = 0;
22+
23+
/// <summary>
24+
/// The length of the file being uploaded, <see cref="Offset"/>. Defaults to 0.
25+
/// If set to -1, the whole file will be uploaded.
26+
/// </summary>
27+
public long Length { get; set; } = 0;
28+
29+
/// <summary>
30+
/// The modification time of the file represented by a double, which is the number of seconds since the UNIX Epoch (Jan 1, 1970)
31+
/// </summary>
32+
public double ModificationTime { get; set; }
33+
}
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace ElectronNET.API.Entities
2+
{
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public class UploadRawData : IPostData
7+
{
8+
/// <summary>
9+
/// The data is available as a Buffer, in the rawData field.
10+
/// </summary>
11+
public string Type { get; } = "rawData";
12+
13+
/// <summary>
14+
/// The raw bytes of the post data in a Buffer.
15+
/// </summary>
16+
public byte[] Bytes { get; set; }
17+
}
18+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy