I need to upload/download file in s3 bucket with user metadata organisationID, OrganisationType, fileType. Filename will be same(file.pdf, file.xls) but it contents will be differ based on organisationID, OrganisationType, fileType
if organisationID =1, OrganisationType=A, fileType = P then i need to download file.pdf
If organisationID =1, OrganisationType=A, fileType = X then i need to download file.xls.
I have below dbouts, How to have same keyname in bucket as filename is same in different scenarios
how to download file based on userMeta files without key
One way to do this is to mimic a hierarchical layout. You could make the key name for oraganizationID=1, OrganizationType=A fileType=P as 1/A/P/file.pdf. Similarly you could make the key name for organisationID=1, OrganisationType=A, fileType=X as 1/A/X/file.xls. Another way is to just embed the metadata in the key name without mimicking a directory structure like 1_A_P_file.pdf. Given the metadata and known file naming logic you can recreate the key name and retrieve the appropriate file. Strip away the metadata in the file name prior to returning the file to the end user.
Related
I am trying to write a groovy script which obtains the source file location, I already tried using
SOurceDataStore.getLogicalSchema().getTechnology().getInternalName()
This only returns "FILE" technology that is being used.
If I wanted to obtain this path:
How can I achieve that?
Method getSchemaName() of class OdiPhysicalSchema can be used to retrieve the schema (or path for the file technology).
Now it looks like you want to retrieve it from a Datastore so you should first find the model, then the logical schema, then the physical schema linked to it through a specific context. You would need an IOdiContextFinder to get the OdiContext object. The code would be something like this :
context = ((IOdiContextFinder)odiInstance.getTransactionalEntityManager().getFinder(OdiContext.class)).findByCode("MY_CONTEXT");
filepath = SOurceDataStore.getModel().getLogicalSchema().getPhysicalSchema(context).getSchemaName();
As far as I see there is only one type of media field which can hold every type of media (image, video, pdf etc.) Is there a way to restrict the media type, so that the field only accepts images and no other filetypes? Because when I allow the field to hold multiple files the array will hold images, video and files. I search for a solution how I can restrict the data types for this field.
You can deal with that by updating the upload function of the upload plugin.
Please for that you will have to check how the extensions folder work.
đź“šDocumentation here: https://strapi.io/documentation/3.0.0-beta.x/concepts/concepts.html#extensions
And after you will have to find the path of the file you want to update.
It will be this one https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-upload/controllers/Upload.js
So you will have to create an empty file at the same path in the extension folder.
It will be ./extensions/upload/folder/Upload.js
module.exports = {
};
In this file you will have to create the function you want to update/override.
It will be this function https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-upload/controllers/Upload.js#L12
So you have to copy this function and past it in your extensions file.
When it's done you can modify the function as you want.
Here in the function https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-upload/controllers/Upload.js#L27 you can see the var files contain all your files, you can simply add your code to test the type of your files.
In macOS, I want a folder action to trigger when I place a new file in that folder. The action should grab the filename, not including the path, and use that as the subject, and then attach the file to an email message and send it. Ideally, this would happen behind the scenes as I don't need to see the activity.
I created an Automator script that can grab the file, extract the name, create and send the file. But it's a bit of a kludge. Once I set a variable to the filename, I lose the attachment and have to get the finder item again. Also, it's not working as a Folder Action which is what I really need.
The Automator includes these steps:
Get Specified Finder Items
Get Folder Contents
Filter Finder Items -- I'm only interested in specific files
Set Value of Variable
--path
Run Shell Script -- extract only the filename without the extension
--basename "$#" .pdf
Set Value of Variable
--fileName
New Mail Message
--Subject: fileName
At this point I no longer can attach the specified file because Automator has 'lost' it, so I have to start over with the Get Specified Finder Items, Get Folder Contents, Filter Finder Items, Add Attachments to Front Message. Finally, Send Outgoing Messages.
What I want to happen is when I place a certain file into a directory, the Folder Action triggers, it looks at the file, and if it meets the filter criteria it emails the file, using only the filename without the extension as the Subject.
Create an Automator document type that is a folder action, and attach it to the desired folder. Items added to the specified folder will be passed on to the workflow, so you don’t need to use additional actions to get them.
You are already saving the filtered item paths in a variable, you just need to get them back for the Mail action:
Folder Action receives files added to { wherever }
Filter Finder Items
Set Value of Variable { Variable: path }
Run Shell Script
Set Value of Variable { Variable: fileName }
Get Value of Variable { Variable: path } (ignore input)
New Mail Message { Subject: fileName } (passed files are attached)
Automator workflows are designed to work with multiple input items as a batch; dealing with items one at a time would require a script or third party action such as Dispense Items Incrementally.
I'd like to create a new stub file "test.mp3" for instance, and add a Window Property to it ( System.Author for instance).
the solution must be usable for several file extension as text, picture, videos, etc...
If I just create a file and use IShellItem2::GetPropertyStore I get a HRESULT fail for invalid Arguments.
Use IShellItem2::GetPropertyStore on a real music file I can read and write Its properties just fine.
Please test your suggestions first.
Property Stores typically access and store data within the file itself. In your case of a mp3 file, it would be attempting to read and write the ID3 tags. Also, Property Stores are not stored in a database and cannot be arbitrarily added to files that don't support it.
You'll most likely need to implement your own property handlers to do what it appears you're trying to accomplish. For types that already have handlers, you'll have to replace the system handlers with your own.
The most likely reason your mp3 test is failing is that you have an empty file with no data and no valid ID3 tags.
I need to control the sub-path of the different different files being managed by MultipleOutputFormat based on the reducer key.
I basically want to set the sub path of the file based on the key given to the reducer.
I can changed the file name by overwrting the generateFileNameForKeyValue method of MultipleOutputFormatbut how can I also change the sub-path of these files?
I mean with just overriding the generateFileNameForKeyValue, I get
mySetJobConfigOutputPath/fileNameBasedKey1.dat
/fileNameBasedKey2.dat
/fileNameBasedKey3.dat
...
but I want to make it to be organize files like below
mySetJobConfigOutputPath/path0ConfiguredInsideReducerBasedOnKey/fileNameBasedKey1.dat
/path1ConfiguredInsideReducerBasedOnKey/fileNameBasedKey2.dat
/fileNameBasedKey3.dat
/path2ConfiguredInsideReducerBasedOnKey/fileNameBasedKey8.dat
as seen, the sub-path and the file name are both figured out by the key inside the reducer.
I know how to configure the file name but was wondering if I can configure the sub-path of the each file under the mySetJobConfigOutputPath folder?
I found out that that I can override the getInputFileBasedOutputFileName method also and give it the sub-Path in there.
#Override
protected String getInputFileBasedOutputFileName(JobConf conf, String Name)
{
//your logic goes here. Simply addd the sub path to the name and return
}
You should still implement the generateFileNameForKeyValue to convert your lead file name to the key
UPDATE: Basically this explains it all http://www.infoq.com/articles/HadoopOutputFormat