Class: Posthubify::MediaResource
- Inherits:
-
Object
- Object
- Posthubify::MediaResource
- Defined in:
- lib/posthubify/resources/posts.rb
Overview
Media assets — upload + signed presign URL (Node sdk .media).
Instance Method Summary collapse
-
#initialize(http) ⇒ MediaResource
constructor
A new instance of MediaResource.
-
#presign(input) ⇒ Object
Signed PUT URL for direct-to-storage upload (5GB; requires R2, otherwise 501).
-
#upload(content, filename = 'upload.bin') ⇒ Object
Upload an image/video (max 64MB) → use the assetId with posts.create({ mediaAssetId }).
Constructor Details
#initialize(http) ⇒ MediaResource
Returns a new instance of MediaResource.
64 65 66 |
# File 'lib/posthubify/resources/posts.rb', line 64 def initialize(http) @http = http end |
Instance Method Details
#presign(input) ⇒ Object
Signed PUT URL for direct-to-storage upload (5GB; requires R2, otherwise 501). input: { ‘fileName’ => …, ‘contentType’ => … }.
76 77 78 |
# File 'lib/posthubify/resources/posts.rb', line 76 def presign(input) @http.data('POST', '/media/presign', body: input) end |
#upload(content, filename = 'upload.bin') ⇒ Object
Upload an image/video (max 64MB) → use the assetId with posts.create({ mediaAssetId }). content = raw byte string (binary string).
70 71 72 |
# File 'lib/posthubify/resources/posts.rb', line 70 def upload(content, filename = 'upload.bin') @http.data('POST', '/media', files: ['file', content, filename]) end |