cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload -upload files where it is stored

Former Member
0 Kudos

Hi Experts,

I have successfully completed <b>Uploading_and_Downloading_files_NW04s_Init</b> (download upload tutorial).

I don't know upload files where it is stored(which location)?

give ur valuable suggestions...

Regards,

P.Manivannan.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If the file is successfully uploaded, it's content is stored in the Web Dynpro context. If you want to save it to disk, you could add the following code to the onActionUploadFile method.

//IWDModifiableBinaryType binaryType =

//byte[] file =

writeByteArrayToFile(new File("/tmp/" + binaryType.getFileName()), file);

The next code is copied from Commons IO's FileUtils

public static FileOutputStream openOutputStream(File file) throws IOException {

if (file.exists()) {

if (file.isDirectory()) {

throw new IOException("File '" + file + "' exists but is a directory");

}

if (file.canWrite() == false) {

throw new IOException("File '" + file + "' cannot be written to");

}

} else {

File parent = file.getParentFile();

if (parent != null && parent.exists() == false) {

if (parent.mkdirs() == false) {

throw new IOException("File '" + file + "' could not be created");

}

}

}

return new FileOutputStream(file);

}

public static void writeByteArrayToFile(File file, byte[] data) throws IOException {

OutputStream out = null;

try {

out = openOutputStream(file);

out.write(data);

} finally {

closeQuietly(out);

}

}

public static void closeQuietly(OutputStream output) {

try {

if (output != null) {

output.close();

}

} catch (IOException ioe) {

// ignore

}

}

Former Member
0 Kudos

Hi kanwalpreet,

I want stored in a KM(Knowledge Management). what can i do. give ur suggestions.

Regards,

P.Manivannan.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

You can see your doc in portal content database pcd, or

while uploading you have specified a path check that path

Regards

Abhijith YS

Former Member
0 Kudos

Hi Abhi,

2. how to go in portal content database?

2. how to see that path?where it can see?

please help

Regards,

P.Manivannan.

Former Member
0 Kudos

Hi

Better you ask your Basis admin or portal consultant they can help you out easily.

Regards

Abhijith YS

Former Member
0 Kudos

Hi,

Thanks for ur replies,

1. I need more information about file upload(where it is stored)...

give ur suggestions. Points still available...

Regards,

P.Manivannan.

Former Member
0 Kudos

chk it

/people/rohit.radhakrishnan/blog/2005/05/27/uploading-files-to-km-repository-using-webdynpro-apis

Former Member
0 Kudos

Hi

Please go through each and every reply in the following link you can get it, dont neglect this thread even if it shows not answered it has solved problem i believe

1 . /thread/99778 [original link is broken]

2 . /thread/310661 [original link is broken]

3. /thread/66561 [original link is broken]

You can also see to a) https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/kmc/knowledge%20ma...

b) http://help.sap.com/saphelp_nw04/helpdata/en/2a/1d95a6ff8e5b49a51960210374ba5b/frameset.htm

Regards

Abhijith YS

Former Member
0 Kudos

Hi all,

Thanks for your replies.

Regards,

P.Manivannan