Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1haKVl-0005Nx-7Z for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2019 13:38:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1haKVj-0008LV-2c for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2019 13:38:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1haKVh-0008LO-7e for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2019 13:38:54 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1haKVX-0000Qf-Ot for pgsql-general@postgresql.org; Mon, 10 Jun 2019 13:38:52 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B579221F92; Mon, 10 Jun 2019 09:38:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 10 Jun 2019 09:38:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=t LlLRE6eGJbX29fK1Y4dhITnpN1EcqW5Tr+Dc/xXpMg=; b=RkB25ymMwfTJ8Azqr YSu1fJXWof34r+pX/CcG4cmCEmH3xRk6XZ1yco6LVzmpuPtFw4XxMixXZVYsq8dL djpub5cilc8fNkb3lly6N9//qgBIPkslYBBP/HpbB0WQ0bcWJWMU90H9Lrx+bsV5 p1aNRHbvvY42pEFHL2GKPzFwwaoRi3sa8lFUDgkhCBHxQiNASkP/klNstHUJ29vt fU9w0DiC6zlZ6rZ15pLOrPqNrWhLn0vk3w2Tc6cdl7AHUKjN19c0BRwgrFHTxb+q LlddC3DPN3edaiwqye1D4CI2G4R0QKOaKpctj0Get8dkt7CJqkeoEhPnaueVlrxS o0HWA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=tLlLRE6eGJbX29fK1Y4dhITnpN1EcqW5Tr+Dc/xXp Mg=; b=Q/P7yRvlyZTchUmaulYPHim6PLBR2C8js95VL0mF2FoHgef47EAtoDDUo 1N1OAVdWGs4uYDlTDyPYrBnZhoRu1hioFWvd/TIbeXCfqdMCWx0eDmDYI5H/aCvb Ld2Xk94gDKnGd6RuOUtZ0HOUNcSvxwUO8VpZoIid3RuxY6RSnuJJOsyWeGExhoMQ eIKKoNMa7wuNgrmz4jFDXzVdJqPCWdTdEDI63GzzoZ5Loor6V3/deNaoaNp5c42C Z530pSg4mZXbV44m2OfC/bUDi4ge9PJZMz7dwpRmXBPNNiXLHbREAnhsvTI9gSAD RKlWzOI0Ze5PX9jTgW1DTkpYoSJfg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudehvddgieekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvddu vddrudehtddrvddtvdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklh grvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 9B45838008A; Mon, 10 Jun 2019 09:38:40 -0400 (EDT) Subject: Re: Inserting into the blob To: Igor Korot Cc: pgsql-general References: <6cbb4f03-7c05-4473-330d-b220b0a9ec7b@aklaver.com> From: Adrian Klaver Message-ID: Date: Mon, 10 Jun 2019 06:38:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/9/19 10:06 AM, Igor Korot wrote: > Hi, Adrian, > > On Sun, Jun 9, 2019 at 11:14 PM Adrian Klaver wrote: >> >> On 6/9/19 8:28 AM, Igor Korot wrote: >>> Hi, ALL, >>> How do I insert the png file (content, not a name) into the BLOB field >>> in the table i PostgreSQL DB? >> >> Are you talking about this data type?: >> >> https://www.postgresql.org/docs/11/datatype-binary.html >> >> Or this?: >> >> https://www.postgresql.org/docs/11/largeobjects.html > > Which one is best to hold an images of unknown size? Probably bytea as it is easier to work with overall. > >> >> What client/language are you using? > > psql if possible. Take a look at(NOTE: need to be superuser): https://www.postgresql.org/docs/current/functions-admin.html pg_read_binary_file is similar to pg_read_file, except that the result is a bytea value; accordingly, no encoding checks are performed. In combination with the convert_from function, this function can be used to read a file in a specified encoding: > > Thank you. > >> >> >>> >>> Thank you. >>> >>> >>> >> >> >> -- >> Adrian Klaver >> adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com