I'm using a Symfony Gaufrette for storing images in a filesystem. It works fine when I store an image first time. But I also need to create a copy of the image after it was uploaded to the filesystem. Is there any way to do it?
I use this function for writing:
$filesystem->write($imagepath, file_get_contents($answer->get('imageObject')->getData()));
I was fighting all day long to make Gaufrette work with my Symfony2 app and Amazon S3 ... whenever I've made a step forward I had to take another fight ...
Finally I've switched to Flysystem and all my problems were gone ...
It's much better written and it just works (although config is almost the same).
Unfortunately copy() method now is not implemented in Gaufrette(you can see it in Adapter interface), so the only way to copy file using this library is to use read() and write() methods.
Related
I'm using CarrierWave for file upload in my project. At the beginning of the implementation process, we've made a mistake and eventually a bunch of objects been uploaded to s3 with minor file naming issues. This was fixed shortly for new uploads.
Now we need to fix all this (let's say thousands) CarierWave/s3 objects broken paths.
Is there any good way to change CarrierWave object with no reuploading?
The part with s3 path update is already done, all I need to do is to change CarrierWave object.
Tried:
img.update(...)
img.raw_attributes_update(...)
...
img.file=...
(with further internal updates to define 'skip' upload var)
Note: re-uploading of all the images is our worst scenario, which I
really want to avoid.
Im trying to figure out how to access the metadata from Amazons3 in Xcode. I found a few examples of code but I am not able to access the S3ObjectMetadatRequest object. Its not even popping up in intellisense. All the other code examples use a lower version of AWS3 sdk for ios. Can anynoe point me in the right direction?
jarmods amnswer is correct there is an object called AWSS3HeadObjectRequest which i would use, But im using the AFNetworking Subclass called "AFAmazonS3Manager". Its a much easier way to implement all the AWS methods plus it expands upon an already greatly managed Networking system. So to be clear jarmods answer is correct but if you want to use the subclass i decided to use the function is "headObjectWithPath".
/res/raw doesn't appear to be an option and saving to SD is fine but i'd prefer to avoid that dependency
Investigating this SharedPrefs appears to be impossible and a bad idea. GestureLibrary.fromPrivateFile() does the job saving the file privately off SD.
I'm trying to make a game in Ruby, and my latest addition is to save files, however, I'm having a major problem with encrypting them.
I already got the saving and loading methods set up, but I don't want to save them in plain-text, because that's begging for cheating. No matter what, the methods I use to try and store them encrypted, compressed, etc., all seem to spring some error on me.
What's the best method for saving text in a file? The only important thing is that the file can't be opened and edited.
You can use crypt gem to encrypt/decrypt your file.
But keep in mind that if your users can view your Ruby script, there's basically no way to hide your data, since any encryptions requires some kind of keys.
What is the best practice when serving files from the Zend Framework MVC? These files have to be served from the MVC as they are protected.
I know you can read in the file and place it into the Response object but this seems like a bad practice as you would be reading the entire file into memory then serving it. Right now I usually do:
header('Content-type: image/jpeg');
fpassthru(fopen($path, 'rb'));
exit;
But this also doesn't seem right as I'm stopping the execution of the script. Any suggestions?
I see nothing wrong with just exit(); What you will need to be careful of is any output buffering layers you may have on (gzip compression, etc). Large files could blow up those buffers pretty quick, so you'll want to close them out and potentially 'chunk' your output with a fopen/fread loop.
I would suggest building a super-simple script for retrieving files based on ticket system like in CMS you generate ticket to DB - filename, unique-hash and than redirect to the super-simple file-retieving script (file.php?hash=asd52ad3as1g5). It will get the hash from query and based on it fetch the real filename and push that to output as you have written using fpassthru. The hash need to be unique and hard to guess...
You could try using the X-Sendfile header. It is supported by lighttpd and newer versions of apache. Basically the webserver will replace the output of the script with the file you specified. The downside being that it is specific to the configuration of the webserver, so you may be on a host that doesn't support it.