Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hubspot-ruby.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "hubspot-ruby"
s.version = "0.9.0"
s.version = "0.9.1"
s.require_paths = ["lib"]
s.authors = ["Andrew DiMichele", "Chris Bisnett", "Vladislav Ermolkin"]
s.description = "hubspot-ruby is a wrapper for the HubSpot REST API"
Expand Down
34 changes: 20 additions & 14 deletions lib/hubspot/file.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
module Hubspot
class File
UPLOAD_FILE_PATH = '/filemanager/api/v2/files'

UPLOAD_FILE_PATH = '/filemanager/api/v3/files/upload'
class << self
def upload(file, params)
query = {
overwrite: params['overwrite'] || false,
hidden: params['hidden'] || false
def upload(file, params = {})
body = {
file: file,
options: JSON.generate(file_options(params)),
folderPath: '/docs'
}
options = {
multipart:
[
{ name: 'files', contents: file },
{ name: 'file_names', contents: params['file_names'] },
{ name: 'folder_paths', contents: params['folder_paths'] }
]

::Hubspot::FilesConnection.post(UPLOAD_FILE_PATH, body: body, params: params)
end

protected

def file_options(params)
{
'access' => params['access'] || 'PUBLIC_INDEXABLE',
'ttl' => params['ttl'] || 'P3M',
'overwrite' => params['overwrite'] || false,
'duplicateValidationStrategy' => params['duplicate_validation_strategy'] || 'NONE',
'duplicateValidationScope' => params['duplicate_validation_scope'] || 'ENTIRE_PORTAL'
}
Hubspot::FilesConnection.post(UPLOAD_FILE_PATH, params: query, body: options)
end
end
end
Expand Down