Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Binäre Datei in DB speichern

Empfohlene Antworten

Hallo , ich hab ne ähnliche problem,

ich will ein binäre datei lesen und in eine Datenbank speichern , aber von 2724b liest nur 59 b !

	

if(!(fp = fopen("file.p12", "rb"))) {

		cout <<"Error reading  file.\n";

		return -1;

	}


	long lSize;

	char * buffer;

	size_t result;



	// obtain file size:

	fseek (fp , 0 , SEEK_END);

	lSize = ftell (fp);

	rewind (fp);


	// allocate memory to contain the whole file:

	buffer = (char*) malloc (sizeof(char)*lSize );


	if (buffer == NULL) {cout << "Memory error\n"; return -1;}


	// copy the file into the buffer:

	result = fread (buffer,1,lSize ,fp);

	if (result != lSize) {cout << "Reading error\n"; return -1;}


	fclose(fp);

        // buffer in DB schreiben ....


Kann jemand helfen ?

Danke !

Warum schlägt man sich freiwillig mit fread und malloc herum, wenn man C++ zur Verfügung hat?

ifstream f("file.p12", ios_base::binary);
f >> noskipws;
vector<char> buffer;
// copy the file into the buffer:
copy(istream_iterator<char>(f), istream_iterator<char>(), back_inserter(buffer));
// buffer in DB schreiben ....
[/code]

Zu deinem Problem: lSize ist 2724, aber result ist 59?

Danke für die schnelle antwort :)

Zu deinem Problem: lSize ist 2724, aber result ist 59?

nein lSize und result sind 2724 , aber wenn ich die buffer in DB speicher (BLOB) ist es nur 59b !

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.