Gui_upload for uploading binary file
Hello All,
I am trying to upload '.jpg' files using gui_upload function.
But something goes wrong and it dumps.
I am new to ABAP.
following is the code i used.
DATA: xline TYPE xstring.
DATA : t_file LIKE TABLE OF xline WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filetype = 'BIN'
filename = 'C:\Documents and Settings\I046674\Desktop\RawTest\images\Image_1000.jpg'
TABLES
data_tab = t_file.
It dumps in the 'GUI_UPLOAD' function itself.
Saying follownig,
==========================================
Error analysis
The error occurred at a statement in the form
ASSIGN f TO <fs> TYPE t
One of these two cases occurred:
1) Field f is a string, a data reference, an object reference, an
internal table or a structure that contains such a field. With the
TYPE addition, this is not possible.
2) Field f is of type x and field symbol <fs> has a character-type type.
When executing the statement, the length of f is not a multiple of
the length (in bytes) of a Unicode character.
===============================================
Can someone help me on this?
Thanks & Regards,
Abhijit
hi,
Master Data Documents Upload ABAP Program
Re: Upload Master Data documents
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'c:\temp\text.txt'
filetype = ' '
IMPORTING
filelength = fleng
TABLES
data_tab = text_tab
EXCEPTIONS
file_write_error = 1
invalid_type = 2
no_authority = 3
unknown_error = 4
OTHERS = 10.
thanks
Similar Messages
-
How to upload binary file in database?
Using servlets..how to upload binary file into database...
How to get the data of file in servlet...
Please reply...i'm unable to find exact code...that i want..You need to do two separate parts: accept the file from a HTTP multi-part POST and then stream it into a BLOB on the database. To do the former, download Jakarta Commons FileUpload. There is extensive documentation on how to write a simple handler for the upload. You then need to send the data to a BLOB. The specifics vary from database to database but generally you will insert or update a row with an empty blob, get a reference to the blob, pipe the data and then commit.
If you do a quick forum search, this question has been asked (and answered) dozens of times. Some of the replies may even have code for you. Best of luck.
- Saish -
How to write a web service for uploading a file
Hi all,
I want to write a web service for uploading a file to some specified folder under application server, how to do that? ThanksI believe the "difference" that you're seeing is that one web service is "RPC" style (The Hello World example) and one web service is "Document" style (The WSDL you have downloaded).
Document-style web service methods always have one element as a parameter, and this parameter manifests itself as a SOAPElement in the service interface.
RPC-style web services are true "remote procedure calls", and are more functional in nature, in that they accept multiple parameters. JAX-RPC will bind these parameters to generated Java types. -
Problem acessing KM in Web dynpro for upload a file
Hello all.
I have a problem to put a file inside a KM repository. I create a context element like a binary - fileData - and like a String - fileName. and the both code then i will show, I give the same error!!
please try to help me, in where is my error...
Code 1:
public void onActionsavePolitic(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionsavePolitic(ServerEvent)
IPrivatePoliticCreationView.IFilenodeElement fileelement= wdContext.createFilenodeElement();
wdContext.nodeFilenode().bind(fileelement);
IWDAttributeInfo attInfo = wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData");
ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
IWDModifiableBinaryType binaryType =(IWDModifiableBinaryType) wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData").getModifiableSimpleType();
IWDNodeElement element = wdContext.getParentElement();
String filename = element.getAttributeAsText("fileName");
if (filename.trim().equals(""))
return;
try {
/*Get an object of current Portal user */
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
com.sapportals.portal.security.usermanagement.IUser ep5User =
WPUMFactory.getUserFactory().getEP5User(sapUser);
ResourceContext context = new ResourceContext(ep5User);
/*Give the path to KM in the variable path */
String path="/documents/News/";
RID rid = RID.getRID(path);
IResourceFactory factory =
ResourceFactory.getInstance();
ICollection folder = (ICollection) factory.getResource(rid,context);
//Using the upload element we can upload the files to a location in the server drive
/*temperory location for writing */
String location = "d:\";
String fileName = location+ fileelement.getFileName();
File file = new File(fileName);
/*Create an output stream for writing to the temperory location*/
FileOutputStream out = new FileOutputStream(file);
out.write(fileelement.getFileData());
out.close();
/*From the temporary location read the file using an input stream*/
FileInputStream fin = new FileInputStream(fileName);
fin.read();
/*Using this input stream we can write to the repository
Content content = new Content(fileelement.getFiledata(),fileelement.get) */
Content content = new Content(fin,"byte", -1);
IResource newResource = folder.createResource(fileelement.getFileName(),null, content);
fin.close();
file.delete();
} catch (NotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (AccessDeniedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WDUMException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UserManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WDRuntimeException e) {
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(""+e.getMessage());
}catch (IllegalArgumentException e) {
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(""+e.getMessage());
//@@end
Code 2:
public void onActionsavePolitic(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionsavePolitic(ServerEvent)
IPrivatePoliticCreationView.IFilenodeElement fileelement= wdContext.createFilenodeElement();
wdContext.nodeFilenode().bind(fileelement);
IWDAttributeInfo attInfo = wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData");
ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
IWDModifiableBinaryType binaryType =(IWDModifiableBinaryType) wdContext.nodeFilenode().getNodeInfo().getAttribute("fileData").getModifiableSimpleType();
IWDNodeElement element = wdContext.getParentElement();
String filename = element.getAttributeAsText("fileName");
if (filename.trim().equals(""))
return;
try {
// Get an object of current Portal user
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
com.sapportals.portal.security.usermanagement.IUser ep5User =
WPUMFactory.getUserFactory().getEP5User(sapUser);
// create an ep5 user from the retrieved user
ResourceContext context = new ResourceContext(ep5User);
// Give the path to KM in the variable path
String repository = "//documents//News//";
RID rid = RID.getRID(repository);
IResourceFactory factory = ResourceFactory.getInstance();
ICollection folder = (ICollection) factory.getResource(rid, context);
byte[] byteArray =
(byte[]) wdContext.currentFilenodeElement().getFileData();
// From the temporary location read the file using an input stream
ByteArrayInputStream fin = new ByteArrayInputStream(byteArray);
// Using this input stream we can write to the repository
Content content =
new Content(fin, binaryType.getMimeType().getHtmlMime(), -1L);
try {
IMutablePropertyMap propertyMap = new MutablePropertyMap();
IResource newResource =
folder.createResource(
wdContext.currentFilenodeElement().getAttributeAsText(
"fileData"),
propertyMap,
content);
} catch (NameAlreadyExistsException re2) {
try {
fin = new ByteArrayInputStream(byteArray);
content =
new Content(
fin,
binaryType.getMimeType().getHtmlMime(),
-1L);
RID fileRid = RID.getRID(repository + filename);
IResource fileResource = factory.getResource(fileRid, context);
fileResource.updateContent(content);
} catch (Exception e) {
wdComponentAPI.getMessageManager().reportSuccess(
"File doesn't exist:" + e.getMessage());
fin.close();
} catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(
"File not found." + e.getMessage(),
true);
} finally {
element.setAttributeValue(wdContext.currentFilenodeElement().getFileName(), null);
//@@end
and the error then I have in same codes is:
java.lang.IllegalArgumentException:
at com.sap.tc.webdynpro.clientserver.data.DataContainer.createLocalPath(DataContainer.java:1347)
at com.sap.tc.webdynpro.clientserver.data.DataContainer.updateAttribute(DataContainer.java:451)
at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.AbstractAdapter.updateAttribute(AbstractAdapter.java:644)
at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.FileUploadAdapter.onFILEUPLOADCHANGE(FileUploadAdapter.java:298)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
com.sap.tc.webdynpro.services.exceptions.WDRuntimeException
at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.handleUIElementEvent(HtmlClient.java:957)
at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.updateEventQueue(HtmlClient.java:372)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.prepareTasks(AbstractClient.java:93)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:294)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:707)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:661)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:229)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:152)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sap.tc.webdynpro.clientimpl.html.client.HtmlClient.handleUIElementEvent(HtmlClient.java:949)
... 25 more
Caused by: java.lang.IllegalArgumentException:
at com.sap.tc.webdynpro.clientserver.data.DataContainer.createLocalPath(DataContainer.java:1347)
at com.sap.tc.webdynpro.clientserver.data.DataContainer.updateAttribute(DataContainer.java:451)
at com.sap.tc.webdynpro.clientserver.uielements.adaptbase.AbstractAdapter.updateAttribute(AbstractAdapter.java:644)
at com.sap.tc.webdynpro.clientserver.uielib.standard.uradapter.FileUploadAdapter.onFILEUPLOADCHANGE(FileUploadAdapter.java:298)
... 30 moreHello
It looks that I have a similar problem - how could you solve your problem.
Thanks in advance
Sascha Fuchs -
GUI_UPLOAD to upload flat file to internal table
Hi Experts,
I have to upload a flat file which has multiple records ,from a local server.The fields in records are ~ saperated.
Presently i am only looking into uploading the flat file into internal table.
I have done the following coding;
TYPES: BEGIN OF gt_frmgt ,
tablety type c length 10 ,
tablenm type c length 30,
numin type c length 2,
END OF gt_frmgt.
TYPES: begin of gt_frmgto,
rec(1000) type c,
end of gt_frmgto.
DATA: Itgt_frmgt type table of gt_frmgt with header line.
DATA: itgt_frmgto type table of gt_frmgto with header line.
DATA: lfile_path type string.
PARAMETERS: f_path type localfile.
at selection-screen on value-request for f_path.
call function 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = f_path.
start-of-selection.
lfile_path = f_path.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = lfile_path
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itgt_frmgto
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
delete itgt_frmgto index 1.
loop at itgt_frmgto.
clear Itgt_frmgt.
split itgt_frmgto-rec at cl_abap_char_utilities=>vertical_tab
into Itgt_frmgt-tablety
Itgt_frmgt-tablenm
Itgt_frmgt-numin.
append Itgt_frmgt.
endloop.
loop at Itgt_frmgt.
write:/ Itgt_frmgt-tablety, Itgt_frmgt-tablenm, Itgt_frmgt-numin.
The input file in Local path is ;
XXXXXXX~~Export the invoice
2~19980501~19980531
// The first invoice:
0~00130698114000010004119980512059611000276233.350.1711076.66????321000789010005???????????????????130601000000000??????????18? 3352051????532611-3357211???~~~
0~????????176233.350.1711076.6676233.350~1510
// The second invoice:
0~00130698114000010007219980512059611000440482.000.175882.00????110108078901007?????????61? 68744479?????????????462088-07?????130601000000000??????????18? 3352051????532611-3357211???????????~~~
0~????????139780.000.175780.0039780.000~1510
0~????3.5"10702.000.17102.0070.20~1510
and the output is :
XXXXXXX~~
2~~1998050
// The fir
0~00~1
0~????~?
// The sec
0~00~1
0~????~?
0~????
I am unable to understand why this split is happening .According to me the first 3 fields should be displayed without field saperater.
It would be very much appreciated if any body has little idea about this.
Thankx,
Priya
Message was edited by:
Priya Parmeshwar Shiggaon
Message was edited by:
Priya Parmeshwar Shiggaonif it is one time upload then u can use transaction CG3Z n upload file on application server.
u can tno use Gui_upload in background.
Program to upload file via gui_upload in foreground -(open fiel in Excel format and then make changes and save it as text tab file and upload tht file) -
REPORT Z_AMIT_BAPI
no standard page heading line-size 255.
parameters: p_file like rlgrap-filename default 'C:\temp\emp.txt'.
data :begin of itab occurs 0,
pernr(8),
bdate(10),
edate(10),
mail(30) ,
end of itab.
Start-of-selection.
Perform read_file.
*& Form read_file
text
--> p1 text
<-- p2 text
FORM read_file .
DATA: full_file_name TYPE string.
full_file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = full_file_name
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ','
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
IF SY-SUBRC <> 0.
MESSAGE e000(000) WITH 'Upload-Error; RC:' sy-subrc.
ENDIF.
ENDFORM. " read_file
reward points if helpfull
amit -
Hi,
I have all the server side stuff working and it receives ordinary file uploads from a form just fine.
However, I now need to use a Java Applet instead of this HTML form and it all goes just fine except the binary file that appears on the server is missing it's 2K header.
This is a very serious problem for me, as I have got to complete this ASAP.
I have been trying to make this work now for 3 days and I cannot find a solution anywhere on the Internet.
any thoughts?
cheers
BruceMy code currently is as follows, sorry all the indenting seems to have vanished after pasting the code in:-
import com.ms.security.*;
import java.lang.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.applet.*;
public class urlFetch extends Applet {
public void UploadFile(String serverURL,
String serverFilePath,
String clientFilePath,
String filename,
// Form values
String func,
String objType,
String objAction,
String parentId,
String CTT_ID,
String nextURL,
String comment,
String InheritRequired,
String CREATE_Required,
String CREATE_Edited,
String CREATE_CacheID,
String CREATE_CatNames,
String name) {
try {
System.out.println("***Get Permission");
PolicyEngine.assertPermission(PermissionID.FILEIO);
System.out.println("***Create URL : " + serverURL);
URL url = new URL(serverURL);
System.out.println("***Create Connection");
URLConnection conn = url.openConnection();
String str = "";
System.out.println("***Create data");
str += "--" + BOUNDARY + NEWLINE;
// Add all the values of the form data fields.
str += _formData("func", func);
str += _formData("objType", objType);
str += _formData("objAction", objAction);
str += _formData("parentId", parentId);
str += formData("CTTID", CTT_ID);
str += _formData("nextURL", nextURL);
str += _formData("comment", comment);
str += _formData("InheritRequired", InheritRequired);
str += _formData("CREATE_Required", CREATE_Required);
str += _formData("CREATE_Edited", CREATE_Edited);
str += _formData("CREATE_CacheID", CREATE_CacheID);
str += _formData("CREATE_CatNames", CREATE_CatNames);
str += _formData("name", name);
byte[] formData = str.getBytes();
str = "";
// add the file
str += "Content-disposition: form-data; name=\"versionFile\"; filename=\"" + filename + "\"";
str += "Content-type: application/msword" + NEWLINE;
str += "Content-Transfer-Encoding: binary" + NEWLINE;
byte[] fileHeader = str.getBytes();
byte[] fileContents = _readFile(clientFilePath);
str = "";
str += NEWLINE; //This is the file content
str += "--" + BOUNDARY + "--" + NEWLINE;
byte[] fileFooter = str.getBytes();
System.out.println("***Setup Request***");
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
int lengthOfData = formData.length + fileHeader.length + fileContents.length + fileFooter.length;
System.out.println("***Data Length : " + lengthOfData);
System.out.println("***File Length : " + fileContents.length);
conn.setRequestProperty("Content-Length", String.valueOf(lengthOfData) );
conn.setDoOutput(true);
conn.setUseCaches(false);
System.out.println("***Get Output Stream");
DataOutputStream os = new DataOutputStream(conn.getOutputStream());
System.out.println("***Connect");
conn.connect();
System.out.println("***Send data");
os.write( formData, 0, formData.length );
os.write( fileHeader, 0, fileHeader.length );
os.write( fileContents, 0, fileContents.length );
os.write( fileFooter, 0, fileFooter.length );
System.out.println("***Flush");
os.flush();
System.out.println("***Close");
os.close();
catch ( Exception e ) {
System.out.println("***** Exception: " + e.toString());
* Split a String on delimiters to return an array of the delimited Strings.
* @param s The String to split up
* @param d The delimiter on which to split s
* @return Array of delimited Strings from s.
private String[] _split(String s, String d) {
StringTokenizer st = new StringTokenizer(s,d);
String[] parts = new String[st.countTokens()];
int i = 0; // Loop counter
while (st.hasMoreTokens())
parts[i++] = st.nextToken();
return parts;
* Create a String which is the HTTP representation of the field name/value pair
* @param fieldName The HTML field name
* @param fieldVal The (String) field value
* @return A String to be used in the HTTP sent to the server.
private String _formData(String fieldName, String fieldVal) {
// return fieldName + " = " + fieldVal + NEWLINE;
return "Content-Disposition: form-data; name=\"" + fieldName + "\"" + NEWLINE + NEWLINE
+ fieldVal + NEWLINE
+ "--" + BOUNDARY + NEWLINE;
* Read the contents of filePath as a String and return.
* @param filePath The full path to the file to be read
* @return A string containing the contents of the file
private byte[] _readFile(String filePath) {
byte[] bytes;
try {
File fileIn = new File(filePath);
FileInputStream fis = new FileInputStream(fileIn);
bytes = new byte[ (int)fileIn.length() ];
fis.read(bytes);
/* my old one
FileReader fr = new FileReader(filePath);
int charsRead = 0;
//my new bits
File fileIn = new File(filePath);
FileInputStream fis = new FileInputStream(fileIn);
int size = ((int) fileIn.length());
bytes = new byte[size];
byte[] aByte = new byte[1];
int n = 0;
for (int i = 0; size > i; i++ ) {
charsRead = fis.read(aByte);
bytes[n] = aByte[0];
++n;
/* mick's original ***
StringBuffer sBuffer = new StringBuffer();
while (charsRead != -1) {
charsRead = fr.read(BUFFER, 0, BUFFER_LEN);
if( charsRead != -1 ) {
sBuffer.append(BUFFER, 0, charsRead);
catch ( Exception e ) {
bytes = new byte[1];
System.out.println("***** Exception xxx: " + e.toString());
// return sBuffer.toString();
return bytes;
* Private statics
private static final String BOUNDARY = "BbC04y";
private static final int BUFFER_LEN = 4096;
private static byte[] BUFFER = new byte[BUFFER_LEN];
private static final String NEWLINE = "\r\n"; -
Upload binary files with Developer Forms
Hi all,
I'm newbie with Forms and I don't know if this question is already answered.
I'm deploying an application involved with blob columns (binary files: pdf, doc, gif, etc) I want to let users to choose files from his PCs (typical "Browse files" button) but I don´t know if this is possible and if yes, how to implement it.
Anybody can help me?
My email is [email protected]
Thanks in advance!
CristinaIf you want to upload direct into the database from the client then No you will need a 9i database or above.
If you want to upload a file from the browser client to the middle tier (Application server) then that will be OK no matter what DB version you are using. Bug of course you'll then need to do the last bit yourself if you want the document / image put into the database. -
Any info on CRC, checksum, or other file integity VIs for large binary files?
Working on send rather large binary files (U16 stream to file) via internet. Would like to check for file integity via CRC or comparable checksum. Would appreciate any comments/suggestions
Hi Brian,
You said;
"Would appreciate any comments/suggestions".
You did not mention what transport mechanism you plan on using.
As I understand ALL of the standard mechanism use CRC of some form to ensure the validity of the packet BEFORE it is ever passed up the OSI 7-Layer model.
TCP/IP based protocols will see to it that all of the segments of a transfer are completed and in order.
UDP on the other hand is a broadcast type protocol and does not ensure any packets are recieved.
So,
At the very worst you should be able to handle your "sanity checks" by simply using a sequence value that is included in your out-going message. The reciever should just have to check if the current seq value is equal to the previous +1.
I co-developed an app that ut
ilized this technique to transfer status messages from a RT platform to a Windows machine. The status messages in this app where concidered FYI, so the sequence counter served as a way of determining if anything was missed.
I am insterested in others thoughts on this subject.
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
How do i specify the filename for a binary file generated by a JSP?
I am writing a report generator that has the ability to generate Excel files. The user clicks on a link (exporter.jsp), the page's content-type has been set to "application/vnd.ms-excel" which naturally prompts the user to either save to a file or open directly in Excel.
It works fine, but requires the user to manually rename the generated file from "exporter.jsp" to "whatever.xls". Furthermore, Firefox will not let you rename the file in save dialog box, it just automatically saves the file as "exporter.jsp", you must rename it from the file browser.
How do specify the output file name from within JSP?
Btw, right clicking and selecting "save link as" allows for specifying the file name, but the file that is created is empty.
ThanksYou need to set the content-disposition header as well as the content-type.
here is one article on the subject
res.setContentType("application/vnd.ms-excel");
res.setHeader("Content-Disposition", "attachment; filename=" + filename); -
Any idea for uploading big file ?
i am working on a website , need to upload FLV video file , the problem i have i can upload the files like jpg with the low size like 500K or 1 MB , but when i try to upload movie file with the 2-3 MB after few minute i get internal error 500. its working on my local system nice but when i try from the hosting , its going crazy.
i use <cffile> to upload . i try <cfftp> and try to upload via ftp protocol but its same . it should not be timeout error because when i run it on my local server and change the destination to upload on hosting server insted of my local server its work perfect and upload the 3mb file in less than minute but when i run it on the hosting server nothing .
anybody has an idea whats going on ?
also it there any chance to have progress bar when useing <cffile > or <cfftp> ?
thanksIt is quite likely that a maximum size limit of around 1 MB has been set in the Administrator of the hosting server. Ask the people who run the server about this.
-
How to use GUI_upload for Uploading a CSV file in Microsoft Excel.
Hi Guys,
can anybody tell me how to Upload the CSV format file in Microsoft excel sheet?
Thanks,
Gopi.Hi Gopi,
u can use GUI_UPLOAD, TEXT_CONVERT_XLS_TO_SAP.
Please check these codes.
Uploading data from CSV file format into internal table using GUI_UPLOAD
REPORT zupload MESSAGE-ID bd.
DATA: w_tab TYPE ZTEST.
DATA: i_tab TYPE STANDARD TABLE OF ZTEST.
DATA: v_subrc(2),
v_recswritten(6).
PARAMETERS: p_file(80)
DEFAULT 'C:\Temp\ZTEST.TXT'.
DATA: filename TYPE string,
w_ans(1) TYPE c.
filename = p_file.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Upload Confirmation'
* DIAGNOSE_OBJECT = ' '
text_question = p_file
text_button_1 = 'Yes'(001)
* ICON_BUTTON_1 = ' '
text_button_2 = 'No'(002)
* ICON_BUTTON_2 = ' '
default_button = '2'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = w_ans
* TABLES
* PARAMETER =
* EXCEPTIONS
* TEXT_NOT_FOUND = 1
* OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CHECK w_ans = 1.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
* FILETYPE = 'ASC
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
* SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
IF sy-subrc <> 0.
v_subrc = sy-subrc.
MESSAGE e899 WITH 'File Open Error' v_subrc.
ENDIF.
INSERT ZTEST FROM TABLE i_tab.
COMMIT WORK AND WAIT.
MESSAGE i899 WITH sy-dbcnt 'Records Written to ZTEST'.
Uploading data from Excel file format into internal table using TEXT_CONVERT_XLS_TO_SAP
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
reward if helpful
raam -
Upload binary file with DSEEntry
Hi ,
I have created a Class for a upload pictures to the IDM Database .
Now I have the problem with the upload.... and the mssql datatype.
At the moment the type is binary(max)
is there any option to add a byte[] to DSEntry.put ?
It seems that DSEntry always try a cast to string , and when put a byte[] I receive an exception.
RegardsUsually binary values are B64 or HEX encoded during processing in IdM. I take it you're trying to write it to a column of datatype binary, not an actual IdM attribute. Perhaps you should use varbinary(max) if you want to exceed 8000 bytes. But, the internal datatypes and the JDBC datatypes are not the same, so for SQL Server you need to use LONGVARBINARY.
see this MicroSoft reference: Using Advanced Data Types
Anyway, here's a working example. The $includebin function is documented in the helpfile but its usage is pretty self explaining in my example here:
My table looks like this: -
Need Help, Finding a site for uploading swf files
[moved from AS3 forum by moderator - is not an AS3 discussion]
Alright, so I'm kind of new to these forums. I searched them thoroughly several times, but couldn't a find a section for what I exactly needed. I used an older version of Flash and actionscript to make some interactive games and then exported them.
I've found plenty of sites that allow uploading of a variety of files, including flash based ones. The problem is that these sites are either for storage, downloading the file onto one's computer, or that they would have to go to a specific link to play the game.
What I want is to be able to place a file onto an uploading site and be able to embed it (I think that's the word) to my own site/forums. That way the game can be played on a site and or discussion forum, without members having to go to another site or downloading the game.
What file uploading site would you recommend for this? I've already tried several, but they don't allow embedding files. I would prefer for the site to be free, as I don't have enough files to make it worth paying a monthly fee.
Thanks in advance for any replies/information!Yes, why not upload it to your own website. Most of sites are not support swf file, but support flv file. To upload swf to your website you can use the code like
<object width="300" height="300">
<param name="movie" value="flashmovie.swf">
<embed src="flashmovie.swf" width="300" height="300">
</embed>
</object>
If you really need to upload swf to other websites, I think you need to convert your video but that will not a game. But maybe you can try to find some flash game websites. -
Function Modules for uploading the file
Hi experts ,
I have a requirement to download a file (csv) from my local sytem (say desktop) into an internal table first and then update the contents of the same internal table into the database table.
Can anybody provide me with a sample program for doing the same or at least the name of function modules for the same.
Prompt replies will be rewarded.
TIA
AbhishekHi Abhishek,
How to use INSERT Statement..
Check this Sample Program..
TABLES:MARA.
DATA:ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
ITAB-MATNR = '123ABCDA'. .
ITAB-MBRSH = 'C'.
ITAB-MTART = 'FERT' .
ITAB-MEINS = 'KG' .
APPEND ITAB.
ITAB-MATNR = '123ABCDB'. .
ITAB-MBRSH = 'C'.
ITAB-MTART = 'FERT' .
ITAB-MEINS = 'KG' .
APPEND ITAB.
LOOP AT ITAB.
INSERT MARA FROM ITAB.
MODIFY MARA .
ENDLOOP. -
Code for uploading a file to server from client
please help me as soon as possible
The Apache > Jakarta > Commons FileUpload package makes it easy to add robust, high-performance, file upload capability to your servlets and web applications.
Maybe you are looking for
-
Hi Experts, Is it possible for me to upload an excel through publisher. I have seen the option of Upload report in publisher.I can upload only .xdo and .zip files. I waant to know wht is this .xdo file. Can i modify this file to upload an excel. Appr
-
Empty page in webdynpro application
Hi All, When i am trying to execute the webynpro application in se80 it i showing the empty page.It is not raising any error message and not giving any short dump.Simply it is showing an empty. When i try to execute the standard applications also.It
-
Ok folks, this has absolutley stumped me. I have 2 sites where I need them to share the same images and thumbnails. I set up on the server (linux/apache) all the pemissions and I'm actually aliasing all the directories. The thumbnails however refu
-
Cisco serie 5500 wireless controller
Hi, We got a cisco serie 5500 wireless controller, software 7.4.110.0. our ssl certicate expired into 2 weeks, we purchase a new one but the SH1 fingerprint is not any more supported and now we must apply SH2. does our controller support SH2? Thanks
-
I keep on getting an error frm-41211 Integration error ssl failure running another product. When I am running a report from a form lorsque j'appele un etat à partir de forms 10 g , il me donne cette erreur FRM 41211 échec SSL pendat l'éxecution d'un