I am trying to use elixir-google-api
to create an application that maintains files and folders on GDrive. I have the following code but am struggling determining exactly how to pass in the name and mimeType.
Has anyone used this api before and can shed some light on where I am going wrong?
Thanks, Peter
def create_folder(name) do
connection
|> File.create(name: name, mimeType: type_folder())
end
def File.create(connection, opts \\ []) do
optional_params =
%{
:ignoreDefaultVisibility => :query,
:keepRevisionForever => :query,
:ocrLanguage => :query,
:supportsTeamDrives => :query,
:useContentAsIndexableText => :query,
:appProperties => :form,
:description => :form,
:folderColorRgb => :form,
:id => :form,
:mimeType => :form,
:modifiedTime => :form,
:name => :form,
:originalFilename => :form,
:parents => :form,
:properties => :form,
:starred => :form,
:viewedByMeTime => :form,
:viewersCanCopyContent => :form,
:writersCanShare => :form
}
|> Map.merge(standard_params())
connection
|> GoogleApi.Drive.V3.Api.Files.drive_files_create(Map.to_list(optional_params), opts)
|> IO.inspect
end
I have a working example.
In mix.exs:
In app.ex:
You can use
drive_files_create_simple
instead ofdrive_files_create_iodata
when you want to upload files.I hope this answer helps you.