Uploading multiples files to alternative directory with alternative name in FuelPHP - upload

I have a form having multiple upload fields. Let's assume a thumbnail image and the large image. Now using the FuelPHP how can i save this two files to two different locations renaming them to name desired.
For example:
I want to save the thumbnail to media/images/thumbnail/db_record_id/thumbnail.extension and the large image to media/images/large/db_record_id/thumbnail.extension
using the answer to this question Multiple uploads to different directories using FuelPHP, I can upload to the desired directories but how to give the desired name?

If you want full control, register a 'before' callback.
If will be called before saving the file, with the File object of that file. It's passed by reference, so you can alter whatever you want.

Related

Where do I place the image data files?

I am working on a ruby on rails project with a requirement of creating a Deal model with an image associated with it, it has other attributes as well but I want to focus on the image aspect. I was thinking about implementing the model by having an attribute called image_file_name. This string will contain the name of the image file. I will store the image file in the folder /app/assets/images. Is this the right way to go about things? I feel that this is the wrong place to place data related files within the application. Where would I keep such image or other media data within the project folder(If I am not using a 3rd party service like AWS).

Make a queue of images on view before upload in mvc

I want to upload multiple files in database in MVC. But before saving the images in server folder, I want to make a list of images on view by selecting images from different folders on client machine. It is possible to upload multiple images using file type input.
But I want to use same file type input to make a collection of images from different locations on my machine and then upload the collection on button click. How to do this?

How to access uploaded files from views

All the uploaded files are stored under
__namespace__/src/__namespace/Controller/logos/file.jpg
and controller file returns only file name "file.jpg" in the view.
So how can I provide path to logo folder in my view in IMG tag
This is where you made the first "Error"! Never store user-data inside your Modules!
When you have users upload data for your module, store them under /data/module-name/! That way you can easily access the files via src="../data/module-name/filename.jpg"
Alternatively, when you want to provide files with your Module and be able to use them, theres a great Module out there called AssetManager, which in turn uses Assetic.

Making my own container file type

I would like to create a file type with a personal extension by combining two other file types, like .mp3 and .pdf.
Later I need to re-open the custom files I've made and be able to use the included files in my app.
How do I do that on iOS?
One option is to append the data of the two files together. Include a few bytes of data at the start that tell you the size of each and maybe their original filenames. Then when you want to recreate the two files from the one custom one, you read your header to get the sizes and names, then use that info to recreate the original files.
Another option would be to zip the two files together. Just give the zip file your own custom extension.
Another option would be to use an NSFileWrapper. Include the two regular files in the wrapper.

Updating iOS application content which include images

I am working on a Vegetable gardening application. Apart from the vegetable name and description I also have vegetable image. Currently, I have all the images in the Supported Files folder in the Xcode project.
But later on I want to update the application dynamically without having the user download a new version. When the user updates the application or downloads new data from the server that data will include the images. Can I store those images in the supporting file folder or somewhere where they can be references by just the name.
RELATED QUESTION:
I will also allow the user to take pictures of their vegetables and then write notes about the vegetables like "just planted", "about to harvest" etc. What is the recommended approach for storing pictures/photos. I can always store them in the user's photo library and then store the reference in the local database and then fetch and display the picture using the reference. The problem with that approach might be that if the user accidentally deletes the picture from the library then it will no longer be displayed in my application.
The only way I see if to store the picture in the app local database as a BLOB.
No you can't put the downloaded images with the others inside the supporting file folder. Also I would suggest you put the images inside an Images or Resources folder instead... If you want to download any data after the app is compiled, then they will not be in the bundle. It is the bundle you are referring to when talking about the Supported Files folder in Xcode. This is read only for your application.
Just to be clear, once compiled, there are no folder structures for your application, these "folders" are just groups in the Xcode project to keep things tidy.
If you download say a zip file containing a set of images, it's up to you to write them to disk after you download them. You should put these images in either the tmp, the cache or the documents directory.
But then you'll have to build your path before loading the images. You won't be able to just provide the name of the file such as:
[UIImage imageNamed:#"something.jpg"];
Because this will look in your bundle. Instead you must do something like this to load your image from the Documents directory for example.
Your challenge is that you will end up in a state where you'll have some images in the Bundle (the ones from when you uploaded your app), and the newer ones in the documents directory. You must them check the bundle first and if there is no image there, check the documents directory.
For user generated data, I suggest also saving the images in the Documents directory, and maintaining an SQLite database of the users data, so you can map an image name to an entry in the database. You don't want to save the images as BLOB because this will inevitably slow down the performance of your queries and add extra unnecessary load on the CPU to convert to UIImage and back.
You don't want to save their images to the gallery for 2 reasons, first this means you'll be saving in 2 places because keeping a reference in your database to an external image is very fragile and you're just asking for trouble, and secondly, once the image isn't under your wing, you don't control it anymore, the user will delete it at some point, if they go back to your app they expect to see it there.

Resources