4D Blog

Home Product Create a BLOB attribute in an object

Create a BLOB attribute in an object

July 20, 2021

Product

With the introduction of classes in the 4D environment, the need to store your data in objects, and especially blobs, has increased. That’s why 4D v19 R2 lets you encapsulate blobs in objects.

Beyond the storage aspect, since the blob object is a reference type, your performance in terms of memory occupation and speed will be greatly improved.

You can now assign a blob as an attribute of an object like you do for numbers, text, or other types:

$o:=New object("blob"; $blob)

or by implicit conversion:

$o:=New object
$o.blob:=$blob

or with a shared object:

$sObj:=New shared object("blob"; $blob)

In a lot of cases, it is better to use a blob object (4D.Blob type) instead of a Blob type. For example, when you pass a blob object in a method or a command parameter, it is not duplicated like a Blob type but passed by reference, just like any other 4D object. This is faster and less memory-consuming:

var $blobObj : Object
 
// Download your MIME in a blob object
$blobObj:=IMAP_transporter.getMIMEAsBlob ( $msgID )
 
// The BLOB object is then passed to the AddToArchives method by reference.
AddToArchives($blobObj)
// Unlike when you pass a Blob type, the blob is not duplicated when handled using a blob object.

But the standard Blob type is not deprecated. Each blob type has its advantages. Use the following table to determine which one suits your needs:

  Blob 4D.Blob
Alterable Yes No
Shareable in objects and collections No Yes
Passed by reference* No Yes
Performance when accessing bytes + –
Maximum size 2GB* Memory

*This size limit may be lower depending on your OS and how much space is available.

Check out the documentation to learn more about this new attribute type!

Now that blobs are managed in objects, there is only one more step for it to be managed in ORDA. Stay tuned!

Discuss

Tags Class, Objects, Programming, Shared object, v19 R2, v20

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy