How to get relative path of a file in a different library? - visual-studio

I have two projects in my solution:
Echipieri.Data (database repository) -> Locations.txt
Echipieri.Web (ASP.NET MVC)
I want to read the locations file from Data but I can't figure out the relative path.
I tryed:
string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Locations.txt");
But it searches in Echipieri.Web not Echipieri.Data. How do I get it to search in Echipieri.Data folder?

Your path is relative to the application/site that is running the code. You need to move your text file to Echipieri.Web and supply the path to the file, or its contents, to your data layer.

Related

Download file based on user metadata fields from S3 bucket in java

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.

ODI Groovy obtaining Directory of Physical schema (Path of source file)

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();

How to Add folder in Minio bucket using c#?

I am using Minio .net client library
my requirement is how can i store my files in folder structure like
ABC is Bucket, CMS is inner folder and CMS folder contains files so how can i achive this ?
amazon s3 doing same things using key value pair i.e ABC/CMS
EDIT:
How can i access files url in my .net project ?
Ex In ABC bucket i have abc.png file so how can i access image to display on HTML tag.
<img src="---any path---/abc.png">
Here is the solution of my own question.
var fileAsStreamData = file.OpenReadStream();
var fileName = "cms/" + file.FileName;
await _minioClient.PutObjectAsync("ASAP", objectName: fileName, data: fileAsStreamData, size: file.Length, contentType: file.ContentType);
Note:where "/" indicating folder structure in minio.
Ex. A/B/C/D/any_file_name so its consider as a inner folder like B is a inner folder of A and C is a inner folder of B and so on.
Creating an object whose name ends with a "/" will create a folder. It is an empty object that simulates a directory. link
I'd like to add that deleting the last object in a directory will also delete your folder. If you do not take that into account in your code, it might lead to bugs and malfunctioning.

Control the MultipleOutputFormat files sub-path

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

Loading a file from filesystem in SPRING

I have been strugling with this for a long while.
I am using an outer API and I need to pass file's path directly. I cannot modify it.
I looks like: functionmethod(String path);
So i cannot use Resource because I need to pass just path.
Is it possible in SPRING?
Maybe you could use:
(new File("")).getAbsolutePath() that gives you the current path (application).
or (I think this one will fit better for you)
getResource("fileName").getFile()

Resources