Giter VIP home page Giter VIP logo

cloudex's People

Contributors

abitdodgy avatar angelikatyborska avatar davepersing avatar dkln avatar erikreedstrom avatar joshsmith avatar kuon avatar manukall avatar nathanl avatar neenaoffline avatar pauloancheta avatar remiq avatar saicoder avatar smeevil avatar sophietroy avatar stareintothebeard avatar suranyami avatar sztheory avatar tyler-pierce avatar wulymammoth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cloudex's Issues

Upload Audio File

I need to upload audio file instead of image. Can I do that with cloudex?

Adding support for retrieving a resource

Do you have any plans to add support for retrieving a resource, in particular from the Admin API? I could certainly just do some quick hacking on my side to make an HTTPoison request (in my case, to try and retrieve the colors histogram). But I wanted to see if this was on your radar since I could ostensibly submit a more fully-featured PR here.

Uploading video and audio files.

In regards to PR-45, "Support for videos", I am still seeing this issue - was this PR merged back to master?
And in regards to PR-1, "Upload Audio FIle", Cloudinary's documentation states that we should use resource_type = video when uploading audio files, such as mp3 files.

Version leniency

Since you mention Phoenix support thought I'd ask if there's room for leniency on the poison and timex dependencies. Phoenix 1.2.1 has a hard limit that is lower which is going to be fixed for poison on their next release but doesn't look like timex. I got around it without a problem like so:

{:timex, "~> 3.1.0", override: true},
{:poison, "~> 3.0.0", override: true},
{:timex_ecto, "~> 3.1.0", override: true}, # required for timex v3+

If you don't feel that's an issue feel free to close this of course

Allow timer 3.2

The requirement is ~> 3.1.7 which is quite strict, timex is 3.2 now.

Cloud.Url.for/2 argument error if just passing `:sign_url` and no transformations

I was just test driving Cloudex and encountered the following issue:

iex> Cloudex.Url.for("public_id", %{sign_url: true})
** (ArgumentError) argument error
    (cloudex) lib/cloudex/url.ex:67: Cloudex.Url.signature_for/3
    (cloudex) lib/cloudex/url.ex:52: Cloudex.Url.for/2

It works when I pass it some valid transformation option:

iex> Cloudex.Url.for("public_id", %{fetch_format: "auto", sign_url: true})
"//res.cloudinary.com/...."

upload return type is incorrect

On this line:

@spec upload(list | [String.t], map) :: [%Cloudex.UploadedImage{}]

We return an %Cloudex.UploadedImage{} when there's only one item.

I do think there may be some deeper issues here, too. For example, the Enum.count(result) is operating on upload_results ++ invalid_list.

Tests failing

After pulling down a fork of this repo and running mix test we get 6 test failures:

  1) test upload multiple image files (CloudexTest)
     test/cloudex/cloudex_test.exs:23
     match (=) failed
     code:  assert [ok: %Cloudex.UploadedImage{}, ok: %Cloudex.UploadedImage{}, ok: %Cloudex.UploadedImage{}] = Cloudex.upload("test/assets/multiple")
     right: [
              error: "Invalid Signature 9c7baa55fde6dac9e588a15c55d6e08e9805e7ae. String to sign - 'timestamp=1518601215'.",
              error: "Invalid Signature 9c7baa55fde6dac9e588a15c55d6e08e9805e7ae. String to sign - 'timestamp=1518601215'.",
              error: "Invalid Signature 9c7baa55fde6dac9e588a15c55d6e08e9805e7ae. String to sign - 'timestamp=1518601215'."
            ]
     stacktrace:
       test/cloudex/cloudex_test.exs:25: (test)

.

  2) test mixed files / urls (CloudexTest)
     test/cloudex/cloudex_test.exs:47
     match (=) failed
     code:  assert [ok: %Cloudex.UploadedImage{}, ok: %Cloudex.UploadedImage{}, error: "File nonexistent.png does not exist."] = Cloudex.upload(["./test/assets/test.jpg", "nonexistent.png", "https://cdn.mhpbooks.com/uploads/2014/10/shutterstock_172896005.jpg"])
     right: [
              error: "Invalid Signature c01b58a90364ab87c87c644d775656cc73acb20b. String to sign - 'timestamp=1518601220'.",
              error: "Invalid Signature c01b58a90364ab87c87c644d775656cc73acb20b. String to sign - 'timestamp=1518601220'.",
              error: "File nonexistent.png does not exist."
            ]
     stacktrace:
       test/cloudex/cloudex_test.exs:49: (test)



  3) test upload with tags (CloudexTest)
     test/cloudex/cloudex_test.exs:62
     ** (MatchError) no match of right hand side value: {:error, "Invalid Signature 5aa78950587ba5b644b2013d839533867a4c588b. String to sign - 'tags=foo,bar&timestamp=1518601223'."}
     code: {:ok, %Cloudex.UploadedImage{tags: ^tags}} =
     stacktrace:
       test/cloudex/cloudex_test.exs:66: (test)



  4) test upload single image file (CloudexTest)
     test/cloudex/cloudex_test.exs:17
     match (=) failed
     code:  assert {:ok, %Cloudex.UploadedImage{}} = Cloudex.upload("test/assets/test.jpg")
     right: {:error,
             "Invalid Signature 9df6d242c28f0ca2c69e8de07dded0667a74ba5e. String to sign - 'timestamp=1518601221'."}
     stacktrace:
       test/cloudex/cloudex_test.exs:19: (test)

.

  5) test upload image url (CloudexTest)
     test/cloudex/cloudex_test.exs:33
     match (=) failed
     code:  assert {:ok, %Cloudex.UploadedImage{}} = Cloudex.upload("http://cdn.mhpbooks.com/uploads/2014/10/shutterstock_172896005.jpg")
     right: {:error,
             "Invalid Signature 2a35268695868d218519042e520d65f7b9a1796a. String to sign - 'timestamp=1518601223'."}
     stacktrace:
       test/cloudex/cloudex_test.exs:35: (test)

...

  6) test upload with phash (CloudexTest)
     test/cloudex/cloudex_test.exs:75
     ** (MatchError) no match of right hand side value: {:error, "Invalid Signature b523ad9a26a6c1f495deb7d4f7162aae2ac465eb. String to sign - 'phash=true&timestamp=1518601222'."}
     code: {:ok, uploaded_image} = Cloudex.upload(["./test/assets/test.jpg"], %{phash: "true"})
     stacktrace:
       test/cloudex/cloudex_test.exs:77: (test)

Support for videos

Cloudinary has support for video uploads by passing the parameter `"resource_type" => "video".

This requires a different URL for the POST request:

https://api.cloudinary.com/v1_1/<cloud_name>/video/upload

I'm in the process of adding this in our fork, and will push a PR as soon as there is a working version.

Deleting images

Hey, this package looks great so far, are there any plans to include Cloudex.delete(public_id) ?

Update for latest timex 3.3.0

When trying to install, I'm already using timex 3.3.0
I get an error

Failed to use "timex" (version 3.3.0) because
  cloudex (versions 1.0.0 and 1.0.1) requires ~> 3.1.7
  mix.lock specifies 3.3.0
defp deps do
    [
      {:phoenix, "~> 1.3.2"},
      {:phoenix_pubsub, "~> 1.0"},
      {:phoenix_ecto, "~> 3.2"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.10"},
      {:phoenix_live_reload, "~> 1.0", only: :dev},
      {:gettext, "~> 0.11"},
      {:cowboy, "~> 1.0"},
      {:comeonin, "~> 4.0"},
      {:argon2_elixir, "~> 1.2"},
      {:timex, "~> 3.1"},
      {:ex_debug_toolbar, "~> 0.4.0"},
      {:earmark, "~> 1.1"},
      {:ecto_autoslug_field, "~> 0.5"},
      {:cloudex, "~> 1.0.0"}
    ]
  end

Cloudex.upload returns list instead of map

From the documentation I was expecting Cloudex.upload to return a traditional {:ok, %Cloudex.UploadedImage{}}. However, the code is returning a list as [ok: %Cloudex.UploadImage{}].

Is this expected? I can understand returning a list if a list was passed as input to the upload method, but not in that form.

Cloudex.delete/1 does not seem to delete asset

I am calling Cloudex.delete(public_id) and my asset is not deleted. Subsequent calls also return the same success tuple, which seems strange as well.

I looked into the code and it seems like the delete_url function might be incorrect - Cloudinary's api shows a destroy slug in the API endpoint.

Delete URL does not include `notification_url`

For async delete operations it is necessary to capture the delete event from the Cloudinary webhook notification. Although notification_url is a supported attribute for the delete url, it is not currently applied when generating the delete url.

Cloud name not drawing from config

Despite my config being as follows

iex(4)> Application.get_env(:cloudex, :cloud_name)
"my_app"

when I run

Cloudex.upload(image_url)

I get {:error, "Invalid cloud_name bmfay"}

What am I missing here?

[error] GenServer :tzdata_release_updater terminating

Hello, I'm receiving this error and I don't know why.

[info] Running LinkService.Endpoint with Cowboy using http://localhost:4000
Interactive Elixir (1.4.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 08 Mar 16:05:55 - info: compiled 6 files into 2 files, copied 3 in 1.6 sec
[debug] Tzdata polling for update.
[error] GenServer :tzdata_release_updater terminating
** (ArgumentError) argument error
    :erlang.hd([])
    (tzdata) lib/tzdata/data_loader.ex:29: Tzdata.DataLoader.content_length_from_headers/1
    (tzdata) lib/tzdata/data_loader.ex:51: Tzdata.DataLoader.do_latest_file_size/1
    (tzdata) lib/tzdata/release_updater.ex:48: Tzdata.ReleaseUpdater.loaded_tzdata_matches_iana_file_size?/0
    (tzdata) lib/tzdata/release_updater.ex:36: Tzdata.ReleaseUpdater.poll_for_update/0
    (tzdata) lib/tzdata/release_updater.ex:17: Tzdata.ReleaseUpdater.handle_info/2
    (stdlib) gen_server.erl:601: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:667: :gen_server.handle_msg/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: :check_if_time_to_update
State: []

Thank you

Using eager transformations in image upload.

I haven't been able to upload images using eager transformations. For my application, I just want to resize images to a certain width by default. Cloudinary seems to support this, and while I understand how to fetch images with certain dimensions using Cloudex.URL.for, I haven't been able to get resizing to work on upload.

I might be missing something obvious.

Make JSON lib configurable

New versions of Phoenix and Ecto are using Jason as the default JSON library. Any interest in making the JSON library configurable? Something like...

config :cloudex, :json_library, Jason

Then, whenever we are calling it, we can do something like...

@json_library Application.get_evn(:cloudex, :json_library)

def foo do
  @json_library.decode!(...)
end

Allow passing cloud name to `Cloudex.Url.for/2`?

Great library, thanks! ๐Ÿ‘ ๐Ÿ˜„

Would you consider a PR to accept the cloud name as a parameter to Cloudex.Url.for/2, leaving the configured value as the default?

I'm currently working around not having this by replacing the cloud name in the returned URL.

    [start, rest] = Regex.split(
      ~r/(http|https):\/\/res.cloudinary.com\/(?<cloud_name>\w+)\/.*/,
      url, on: [:cloud_name]
    )
    Enum.join([start, desired_cloud_name, rest])

Compilation error when using phoenix helper

Trying to use the phoenix helper snippet I get a compile error:

== Compilation error in file lib/my_app_web/views/cloudex_image_helper.ex ==
** (CompileError) lib/my_app_web/views/cloudex_image_helper.ex:15: undefined function picture/0

I guess that's a leftover and is meant to actually read options[:width] instead of picture.width etc.?
Or is picture some convenience function of Phoenix that I'm missing?

First process supervisor

We use cloudex in our phoenix application (it's been very handy, by the way) and a few weeks a go we found a problem trying out phoenix_live_dashboard , more information in:

https://github.com/phoenixframework/phoenix_live_dashboard/issues/156

despite it was a problem with phoenix_live_dashboard the main reason was that cloudex first process is a GenServer instead of a supervisor, is there any plan to change this?

additional information:

https://github.com/elixir-lang/elixir/issues/10096

Timeouts on upload can't be configured

Currently the duration for an upload request is limited to hackney's default, which is 5 seconds. This means we're seeing a lot of timeouts for uploading large images (or running a dev server on not-the-world's-best-internet).

This code:
https://github.com/smeevil/cloudex/blob/master/lib/cloudex.ex#L33
looks like it should set it to 60 seconds, but it doesn't.

The timeout can be manually overridden by adding timeout and/or recv_timeout options here:
https://github.com/smeevil/cloudex/blob/master/lib/cloudex/cloudinary_api.ex#L116-L122
But ideally should be configurable from the calling application.

I suspect this will also affect any of the other API operations that have the manual 60-second Task.await call.

Uploading images via Plug.Upload path

Hey all,

I'm unable to upload images from a Plug.Upload struct coming from a multipart form. The error I'm getting is {:error, {:invalid, "<"}} when using the live api, and [error: {:invalid, "<"}] when using Cloudex.upload. Is uploading via Plug.Upload supported or do I need to do something like send it to S3 first and then use that URL?

Pattern matching on Cloudex.upload/2 departs from Elixir conventions?

Correct me if I'm wrong, but it seems that pattern matching for Cloudex.upload/2 departs from Elixir conventions.

Normally, in Elixir we do something like this:

case func do
  {:ok, result} ->
    # ...
  {:error, reason} ->
    # ...
end

Cloudex returns a list, however. How come?

case Cloudex.upload("foo.jpg") do
  [ok: result] ->
    # ...
  [error: reason} ->
    # ...
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.