I have a usecase, where I have uploaded a file using carrierwave fog-google on GCS bucket. However using some other code, I am processing the same file then re-uploading it after changing size and name from google-cloud-storage APIs. Now at the same location we have two files. One is original and other one is processed file.
Here my query is, how to update the new file attributes in carrierwave active record stored in mongoDB for the original file. I want to update the file location, url, name, path all other attributes etc from the original file to processed file.
Is there any way we can achieve it using carrierwave functionality. Any help would be appriciated.
Related
I'm working on a Laravel API project, let see when you upload a image I change the colors, with a shell script. The api accepts urls so that means I have to save the image in a temp folder so that I can edit it and save it to my S3 filesystem. Is it convenient that I save the temp image in the S3 filesystems or local?
It will likely be much faster to save the image locally in a temp directory to make the changes before storing it on S3. You can use sys_get_temp_dir() to get a path used for temporary files.
https://secure.php.net/manual/en/function.sys-get-temp-dir.php
I am using the latest CKEditor (4.9.2). I have integrated it successfully with a file browser (DevExpress) and everything works fine.
I use an initial upload path, common for both files and images. This directory has a quite large and complex structure (usually up to 6-7 levels). If the user wants to replace an existing image or file the file browser opens and he has to open six or seven folders in order to get to the folder that the new image is stored. Usually, the images the users replace are stored in the same folder with the one they are replacing. In my opinion, that should be the default behavior. If I select to see an existing image’s properties and then I hit the “Browse Server” button, to have the file browser to open in the folder the image resides.
Is there any way to pass the current image path, in the image url field, to the file manager? In that case with a little parsing I can set the file browser’s initial path to the same folder the existing image is stored.
Is that possible? I imagine that we must first get the image path from the image URL field and alter the “Browse Server” button’s code to pass it as a url parameter to the file browser.
This is a bit 'hackish', but inside your file manager, you can use this to get the existing value of URL field:
window.opener.CKEDITOR.document.$.getElementsByClassName('cke_dialog_image_url')[0].querySelector('input').value
cke_dialog_image_url is the CSS classname of the table that has the URL input field.
In order to place images in the web store, they have to be uploaded to the file cabinet and then the file name needs to be associated with the item.
What I am looking to do, is to source the images from my current internal storage to NetSuite and still be able to view the images on the website. I am trying to find a way to do this because I don't want to have to upload them all individually or with a mass upload.
You will need to create a custom item field of type "text" and associate the field to the item record.
You can then place the full path to your image in the field you just created and reference the custom field in your templates.
This will allow you to use urls from your own host, but dynamically be able to use them within the NetSuite web store.
I am currently using carrierwave-aws to upload to my S3 bucket.
One issue I am having is after the image is uploaded and saved, if the user, lets say changed something about the image locally and re-submitted for upload with the same file name, it will not reflect the new file uploaded.
The user has to change some part of the file name for it to show the correct one in my application.
I am assuming this is a caching issue but not sure where to begin to address this matter.
Has anyone else experienced this?
If your S3 bucket is set with a long or infinite expiry (which is a good idea for performance), you'll need to change the filename each time the image changes. See the Carrierwave wiki page on how to do this.
I use Core Data to store the URL path of the image file in my document, how to backup both of them to mac/PC, I copy the sqlite file and the image out through iTune, and when I copy them back to iPhone, the sqlite seem to be ok, but the image didn't show up. I think the path has changed.
what can I do?
I have done something similar. Two things were key to making this architecture work.
The image files must be stored in a consistent location relative to the Core Data store file.
The URL/path stored in Core Data for the image is a relative one, not absolute. The image path is made relative to the Core Data store file.
Relative Location on Filesystem
I stored all images in a subdirectory named "Images" that lived in the same directory as the Core Data store file. E.g.
parent directory/
--> MyCoreDataStore.sql
--> Images/
-----> SomeImage1.png
-----> SomeImage2.png
Essentially, I treat the application's data as a file package: a directory containing multiple related files that all together comprise the application data or data document.
Relative image URLs
URLs (or paths) to images must be constructed at runtime. The Core Data store holds a relative path/URL to each image's location. The location is relative to the location of the Core Data store file. Your app always knows the full path/URL to the Core Data store.
I build the full path to an image location when needed using the parent directory of the Core Data store file and the relative image path held in the Core Data db.