Code Monkey home page Code Monkey logo

files-com / files-sdk-ruby Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 7.0 17.58 MB

Files.com Official Ruby SDK. Files.com is Cloud Storage, Cloud Gateway, and MFT, All In One. Our built-in storage is fast, affordable, and available in 7 Worldwide Regions. Access Any File on Any Cloud via Files.com's Ruby client, including Google, Amazon, Microsoft, Box, Dropbox, Amazon, Wasabi, Backblaze, Rackspace, and more.

Home Page: https://developers.files.com/

License: MIT License

Ruby 99.99% Shell 0.01%

files-sdk-ruby's People

Contributors

bombino avatar files-opensource-bot avatar

Stargazers

 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  avatar  avatar  avatar

files-sdk-ruby's Issues

Where to set Files API Key

I keep getting this error:

Files::AuthenticationError (No Files.com API key provided. Set your API key using "Files.api_key = <API-KEY>". You can generate API keys from the Files.com's web interface. ):

I am setting the API Key in my application in config/file.rb with the code snippet:

Files.api_key = ENV.fetch('MY_KEY', Rails.application.credentials[:my_key])

Is this not the correct way to do it?

Upload a whole directory that contain images

I have an image under public/images/test.jpeg

I would like to upload the entire public/images folder and its contents to uploads/images folder in files.com

According here

def self.upload_file(path, destination = nil, options = {})

the upload_file accepts path and destination

I tried this approach

dir = File.join(Rails.root, 'public', 'images')
file = File.new(dir)

Files::File.upload_file(file, "uploads/images")

But i'm currently getting this error


TypeError: no implicit conversion of Symbol into Integer
from /Users/*****/.rvm/gems/ruby-2.6.0/gems/files.com-1.0.43/lib/files.com/models/file_part_upload.rb:64:in `partsize'

I also checked the documentation https://github.com/Files-com/files-sdk-ruby/blob/master/docs/file.md#upload-file

and tried this approach

dir = File.join(Rails.root, 'public', 'images')

Files::File.create(dir, 
  length: 1, 
  mkdir_parents: true, 
  part: 1, 
  parts: 1, 
  provided_mtime: "2000-01-01T01:00:00Z", 
  restart: 1, 
  size: 1, 
  with_rename: true
)

but I'm getting

Files::InvalidRequestError: Bad request
from /Users/***/.rvm/gems/ruby-2.6.0/gems/files.com-1.0.43/lib/files.com/api_client.rb:253:in `handle_error_response'

Filter by question

filter (string): If specified, will filter folders/files list by this string. Wildcards of * and ? are acceptable here.

Just wanted to confirm that the filter functionality is strictly by string.

I am looking to query all files after a certain date, can you recommend a path?

Issue in create Inbox behaviour

Hi
I am trying to create a inbox behaviour but it returns me below error

Files::APIError: Value is invalid
from /home/ankit/.rvm/gems/ruby-2.5.3@cview/gems/files.com-1.0.31/lib/files.com/api_client.rb:224:in `handle_error_response'
Caused by Faraday::UnprocessableEntityError: the server responded with status 422
from /home/ankit/.rvm/gems/ruby-2.5.3@cview/gems/faraday-1.0.1/lib/faraday/response/raise_error.rb:30:in `on_complete

Request code

json = { "key": "sample-test",  "title": "Upload here",   "show_on_login_page": true,  "require_registration": false,  "password": "password" }

Files::Behavior.create(value: json.to_s, path: "path", behavior: "inbox")

I am getting successful response when I tried with curl request.

curl https://app.files.com/api/rest/v1/behaviors.json \
  -X POST \
  -H 'Content-Type: application/json' \
  -d  '{"path":"PATH","behavior":"inbox","value":{"key":"sample-test","title":"Upload here","require_registration":false,"show_on_login_page":false,"dont_separate_submissions_by_folder":true, "password": "PASSWORD"}}' -H 'X-FilesAPI-Key: API_KEY'

Can you please let me know how to pass json value in value key?

Files::Dir fails with undefined method exception

Attempting to follow the documentation and the List using array syntax example is failing with what appears to be an internal bug:

[7] pry(main)> Files::Dir['/']
NoMethodError: undefined method `list' for Files::Folder:Class
from /home/tom/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/files.com-1.0.25/lib/files.com/models/folder.rb:58:in `find_recursive'
[8] pry(main)> 
$ gem list | grep files
files.com (1.0.25)

Create a webhook POST

Hi is there a way to use the API to create a webhook that uses the POST method.

I am looking at the documentation how ever not enough data for POST
https://developers.files.com/#create-behavior

Basically I want to automate webhook below:
Screen Shot 2021-02-16 at 1 40 03 PM

I am making a wild guess below any help will be appriciated.

Files::Behavior.create(
  url: 'https://example.com/webhooks/incoming',
  path: 'development/foo',
  value: { 
    method: :POST, 
    encoding: :JSON, 
    triggers: %w[create],
    headers: { 'api-key': 'some-super-secret' },
    body: { id: 1234 }
  }.to_json, 
  behavior: 'webhook'
)

Thank you.

downloading a file problem

Hello, I'm trying to download a file using the following code:

file = Files::Dir.list_for("some/path/to/a/folder/with/jpeg/files").first
file.download_file(File.join(Rails.root, "tmp", "test.jpeg"))

Something does get downloaded but it's definitely not the jpeg file. the downloaded file also doesn't seem to have the same file size, looks to be actually double in size - this happens to any file i try to download like this

any pointers if downloading should be done differently or if there's an issue somewhere?

Gem attempts to loads files from nonexistent location

Hello!

It looks like the change here moved from requiring files in the models directory to requiring files in the clients directory. However, there is no clients directory in the gem, so this gem cannot be loaded.

Let me know if I can provide any more info โ€” this issue is preventing us from upgrading our version of this gem past 1.0.188, it would be great to get this fixed!

Files with spaces

The ruby client fails when working with files with spaces. This can be repeated by putting a text file with a space in the name and then download and run file.read using the client.

Also, the file.rewind function needs to be properly implemented. The Gem only allows one read.

Create folder

Hi does anyone know how to create a folder?

I tried

Files::Automation.create(
  automation: 'create_folder',
  trigger: 'realtime', 
  path:'development/test',
  destination: 'success'
)

Also tried

Files::Automation.create(
  automation: 'create_folder',
  trigger: 'realtime', 
  source: '',
  destination: '',
  trigger_actions: %w[create],
  trigger_action_path: 'development/test/success'
)

I always get the same error
Files::APIError ([HTTP 422] Error saving model.)

Looking at the document it does not make sense to me.
https://developers.files.com/#create-folder

Doc

path

Path on which this Automation runs. Supports globs. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.

Thanks

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.