1
1
from pubnub .endpoints .file_operations .file_based_endpoint import FileOperationEndpoint
2
-
3
2
from pubnub .crypto import PubNubFileCrypto
4
3
from pubnub .enums import HttpMethod , PNOperationType
5
4
from pubnub .models .consumer .file import PNSendFileResult
6
5
from pubnub .endpoints .file_operations .publish_file_message import PublishFileMessage
7
6
from pubnub .endpoints .file_operations .fetch_upload_details import FetchFileUploadS3Data
8
7
from pubnub .request_handlers .requests_handler import RequestsRequestHandler
9
8
from pubnub .endpoints .mixins import TimeTokenOverrideMixin
10
-
9
+ from pubnub .models .consumer .message_type import PNMessageType
10
+ from typing import Union
11
11
12
12
class SendFileNative (FileOperationEndpoint , TimeTokenOverrideMixin ):
13
13
def __init__ (self , pubnub ):
@@ -23,6 +23,8 @@ def __init__(self, pubnub):
23
23
self ._file_object = None
24
24
self ._replicate = None
25
25
self ._ptto = None
26
+ self ._message_type = None
27
+ self ._space_id = None
26
28
27
29
def file_object (self , fd ):
28
30
self ._file_object = fd
@@ -69,7 +71,16 @@ def is_compressable(self):
69
71
return True
70
72
71
73
def custom_params (self ):
72
- return {}
74
+ import ipdb
75
+ ipdb .set_trace ()
76
+ params = {}
77
+ if self ._message_type is not None :
78
+ params ['type' ] = str (self ._message_type )
79
+
80
+ if self ._space_id is not None :
81
+ params ['space-id' ] = str (self ._space_id )
82
+
83
+ return params
73
84
74
85
def validate_params (self ):
75
86
self .validate_subscribe_key ()
@@ -110,6 +121,14 @@ def cipher_key(self, cipher_key):
110
121
self ._cipher_key = cipher_key
111
122
return self
112
123
124
+ def message_type (self , message_type : Union [PNMessageType , str ]):
125
+ self ._message_type = message_type
126
+ return self
127
+
128
+ def space_id (self , space_id ):
129
+ self ._space_id = str (space_id )
130
+ return self
131
+
113
132
def create_response (self , envelope , data = None ):
114
133
return PNSendFileResult (envelope , self ._file_upload_envelope )
115
134
0 commit comments