Module: JPSClient::API::File
- Included in:
- Client
- Defined in:
- lib/jpsclient/api/file.rb
Overview
文件上传相关 API 处理 /api/file/* 路径的所有接口
Instance Method Summary collapse
-
#complete_file_multipart(s3_key:, upload_id:, upload_config:) ⇒ Object
完成多部分上传.
-
#get_file_sign_url(s3_key:, upload_id:, part_id:, upload_config:) ⇒ Object
获取分片预签名URL.
-
#get_simple_sign_url(s3_key:, upload_config:) ⇒ Hash
获取简单上传预签名URL(用于小文件直接上传,使用 media 配置).
-
#init_file_multipart(s3_key:, content_type: "", upload_config:) ⇒ Object
初始化多部分上传.
Instance Method Details
#complete_file_multipart(s3_key:, upload_id:, upload_config:) ⇒ Object
完成多部分上传
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jpsclient/api/file.rb', line 56 def complete_file_multipart(s3_key:, upload_id:, upload_config:) path = @request_config["file_complete_multipart"]["url"] body_params = { s3Key: s3_key, uploadId: upload_id, uploadType: upload_config.upload_type, bucketName: upload_config.bucket_name, region: upload_config.region } return request_with_auth(:post, path, body: body_params) end |
#get_file_sign_url(s3_key:, upload_id:, part_id:, upload_config:) ⇒ Object
获取分片预签名URL
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/jpsclient/api/file.rb', line 40 def get_file_sign_url(s3_key:, upload_id:, part_id:, upload_config:) path = @request_config["file_sign_url"]["url"] body_params = { s3Key: s3_key, uploadType: upload_config.upload_type, uploadId: upload_id, partId: part_id, bucketName: upload_config.bucket_name, region: upload_config.region } return request_with_auth(:post, path, body: body_params) end |
#get_simple_sign_url(s3_key:, upload_config:) ⇒ Hash
获取简单上传预签名URL(用于小文件直接上传,使用 media 配置)
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jpsclient/api/file.rb', line 26 def get_simple_sign_url(s3_key:, upload_config:) path = @request_config["file_sign_url"]["url"] body_params = { s3Key: s3_key, uploadType: upload_config.upload_type, bucketName: upload_config.media_bucket_name, region: upload_config.media_region } return request_with_auth(:post, path, body: body_params) end |
#init_file_multipart(s3_key:, content_type: "", upload_config:) ⇒ Object
初始化多部分上传
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jpsclient/api/file.rb', line 8 def init_file_multipart(s3_key:, content_type: "", upload_config:) path = @request_config["file_init_multipart"]["url"] body_params = { s3Key: s3_key, contentType: content_type, uploadType: upload_config.upload_type, bucketName: upload_config.bucket_name, region: upload_config.region } return request_with_auth(:post, path, body: body_params) end |