Git Product home page Git Product logo

shrine-memory's People

Contributors

janko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

shrine-memory's Issues

Accessing Stored File

I'm not sure if I should be able to do this with the gem anyway. I am using Shrine memory for my test environment. I am trying to write a feature spec to check a process in which a user uploads a CSV, matches up the files headers and it processes it. I've setup shrine memory in the initialiser as below:

if Rails.env.test?
  require 'shrine/storage/memory'
  Shrine.storages = {
    cache: Shrine::Storage::Memory.new,
    store: Shrine::Storage::Memory.new,
  }
else

I am then adding a csv file in my factory which I want to use later in my controller. I run the FactoryGirl factory in my spec and it all seems to work fine. When inspecting it I get back a url of it in memory. However when I visit the page where I am matching up the headers of the csv file it fails. It says it is unable to find the file in memory. As I need to open the file to find out what the headers are.

Should/would the file created in the factory actually be accessible, if it is meant to be what am I doing wrong? If not is their a way I can force the model to point to a file I store somewhere else?

`Shrine.storages[:cache].storage` unavailable

I'm using the shrine-imgix plugin in combination with S3 like so:

imgix = Shrine::Storage::Imgix.new(
  storage:          Shrine::Storage::S3.new(**s3_options),
  include_prefix:   true, # set to false if you have prefix configured in Imgix source
  api_key:          "xzy123",                 #
  host:             "my-subdomain.imgix.net", # Imgix::Client options
  secure_url_token: "abc123", # optional      #
)

Shrine.storages[:store] = imgix

I'm also using direct uploads with the presign_endpoint plugin.

As part of the upload process I show the user a preview of the image they are uploading, before they submit the form. I generate the URL of this image using the following code:

path = []
path << Shrine.storages[:cache].storage.prefix
path << File.basename(params[:key])
path = path.join("/")
imgix = Shrine.storages[:cache].client
url = imgix.path(path).to_url(w: 125, h: 125, dpr: 2, fit: "crop")

For my tests I want to use shrine-memory, but the above URL generation code relies on the Shrine.storages[:cache].storage method which isn't available in shrine-memory.

Is there a workaround for this using this gem? I don't need an actual working URL obviously, but ideally shrine-memory would be able to mimic's shrine-imgix interface.

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.